B - Almost GCD Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 200

問題文

数列 A\ (A_1, A_2, A_3, \dots, A_N) が与えられます。
正の整数 kGCD 度を、A_1, A_2, A_3, \dots, A_N のうち k で割り切れるものの数と定義します。
2 以上の整数のうち GCD 度が最大になるものを一つ求めてください。 GCD 度が最大のものが複数ある場合どれを出力しても構いません。

制約

  • 1 \le N \le 100
  • 2 \le A_i \le 1000
  • 入力は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N
A_1 \hspace{7pt} A_2 \hspace{7pt} A_3 \hspace{5pt} \dots \hspace{5pt} A_N

出力

2 以上の整数のうち GCD 度が最大になるものを一つ出力せよ。GCD 度が最大のものが複数ある場合どれを出力してもよい。


入力例 1

3
3 12 7

出力例 1

3

3, 12, 7 のうち、 3, 122 つが 3 で割り切れるので 3 の GCD 度は 2 です。
2 以上の整数でこれより大きい GCD 度を持つものは存在しないので 3 は正答です。


入力例 2

5
8 9 18 90 72

出力例 2

9

この場合、 9 の GCD 度は 4 です。
23 の GCD 度も同じく 4 なので 23 を出力しても構いません。


入力例 3

5
1000 1000 1000 1000 1000

出力例 3

1000

Score : 200 points

Problem Statement

Given is an integer sequence A: A_1, A_2, A_3, \dots, A_N.
Let the GCD-ness of a positive integer k be the number of elements among A_1, A_2, A_3, \dots, A_N that are divisible by k.
Among the integers greater than or equal to 2, find the integer with the greatest GCD-ness. If there are multiple such integers, you may print any of them.

Constraints

  • 1 \le N \le 100
  • 2 \le A_i \le 1000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 \hspace{7pt} A_2 \hspace{7pt} A_3 \hspace{5pt} \dots \hspace{5pt} A_N

Output

Print an integer with the greatest GCD-ness among the integers greater than or equal to 2. If there are multiple such integers, any of them will be accepted.


Sample Input 1

3
3 12 7

Sample Output 1

3

Among 3, 12, and 7, two of them - 3 and 12 - are divisible by 3, so the GCD-ness of 3 is 2.
No integer greater than or equal to 2 has greater GCD-ness, so 3 is a correct answer.


Sample Input 2

5
8 9 18 90 72

Sample Output 2

9

In this case, the GCD-ness of 9 is 4.
2 and 3 also have the GCD-ness of 4, so you may also print 2 or 3.


Sample Input 3

5
1000 1000 1000 1000 1000

Sample Output 3

1000