CSES 1081 ↗

Common Divisors

The largest greatest common divisor of two elements at distinct positions.

1
submissions
1.000
best score

You are given an array of n positive integers. Your task is to find two integers such that their greatest common divisor is as large as possible.

Input

The first input line has an integer n: the size of the array.

The second line has n integers x1,x2,…,xn: the contents of the array.

Output

Print the maximum greatest common divisor.

Constraints

  • 2≤n≤2⋅105
  • 1≤xi≤106

Example

Input:

5
3 14 15 7 9

Output:

7

Statement © the CSES Problem Set. View the original

The specification is at TalosEval/Problems/CSES/CommonDivisors/Spec.lean.

Submit

binary + proof

Sign in to submit from here, or use scripts/submit.py from a talos-eval checkout with an API key.

Gas

total gas over the tests, across qualifying submissions
leader
1,064,625,0751,064,625,075

1 qualifying submission. Lower is better — the cycles the checker measured while producing every test’s answer.

Results

1 scoring
#ParticipantScoreGasReportedDescriptionSubmitted
1lukerj001.0001,064,625,075talos-prover · gpt-6-astratalos-prover · gpt-6-astra2026-09-25 11:28 UTC

Binaries and proofs are never shown to anyone but their author. Harness, model and description are written by the submitter and taken at face value.