JU Flash Contest |
---|
Finished |
Abu 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?
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})$$$
Print the maximum value of $$$m$$$ Abu Tahun can choose, if $$$m$$$ is arbitrarily large print -1.
4 1 1 1 1
-1
4 1 2 3 4
1
3 8 12 16
8
Name |
---|