JU Flash Contest |
---|

Finished |

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

The problem statement has recently been changed. View the changes.

×
I. Abu Tahun Mod problem

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputAbu Tahun loves palindromes.

An array is palindrome if it reads the same backwards and forwards, for example arrays $$$\{1\}$$$, $$$\{1,1,1\}$$$, $$$\{1,2,1\}$$$ , $$$\{1,3,2,3,1\}$$$ are palindrome, but arrays $$$\{11,3,5,11\}$$$, $$$\{1,12\}$$$ are not.

Abu Tahun has an array of $$$n$$$ integers $$$A$$$. He wants his array to be palindrome. He can choose an integer $$$m$$$, then change the value of all $$$A_i$$$ $$$(1 \leq i \leq n)$$$ to ($$$A_i\mod m$$$).

what is the maximum value of $$$m$$$ he can choose, such that the array becomes palindrome?

Input

The first line of input contains a single integer $$$n$$$ $$$( 1 \leq n \leq 10^{5})$$$

The second line contains integers $$$A_1$$$,$$$A_2$$$,...,$$$A_n$$$ $$$(1 \leq A_i \leq 10^{9})$$$

Output

Print the maximum value of $$$m$$$ Abu Tahun can choose, if $$$m$$$ is arbitrarily large print -1.

Examples

Input

4 1 1 1 1

Output

-1

Input

4 1 2 3 4

Output

1

Input

3 8 12 16

Output

8

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: May/23/2024 21:54:44 (j1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|