{"raw_statement":[{"iden":"statement","content":"Abu Tahun loves palindromes.\n\nAn 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.\n\nAbu 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 <= i <= n)$ to ($A_i mod m$).\n\nwhat is the maximum value of $m$ he can choose, such that the array becomes palindrome?\n\nThe first line of input contains a single integer $n$ $(1 <= n <= 10^5)$\n\nThe second line contains integers $A_1$,$A_2$,...,$A_n$ $(1 <= A_i <= 10^9)$\n\nPrint the maximum value of $m$ Abu Tahun can choose, if $m$ is arbitrarily large print -1.\n\n"},{"iden":"input","content":"The first line of input contains a single integer $n$ $(1 <= n <= 10^5)$The second line contains integers $A_1$,$A_2$,...,$A_n$ $(1 <= A_i <= 10^9)$"},{"iden":"output","content":"Print the maximum value of $m$ Abu Tahun can choose, if $m$ is arbitrarily large print -1."},{"iden":"examples","content":"Input4\n1 1 1 1\nOutput-1Input4\n1 2 3 4\nOutput1\nInput3\n8 12 16\nOutput8\n"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the length of the array.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence of positive integers.  \n\n**Constraints**  \n1. $ 1 \\leq n \\leq 10^5 $  \n2. $ 1 \\leq a_i \\leq 10^9 $ for all $ i \\in \\{1, \\dots, n\\} $  \n\n**Objective**  \nFind the maximum integer $ m \\geq 1 $ such that the array $ B = (a_1 \\bmod m, a_2 \\bmod m, \\dots, a_n \\bmod m) $ is a palindrome.  \nIf no such maximum exists (i.e., $ m $ can be arbitrarily large), output $ -1 $.  \n\n**Key Condition**  \nFor $ B $ to be a palindrome:  \n$$\na_i \\bmod m = a_{n+1-i} \\bmod m \\quad \\forall i \\in \\{1, \\dots, \\lfloor n/2 \\rfloor\\}\n$$  \nThis is equivalent to:  \n$$\nm \\mid (a_i - a_{n+1-i}) \\quad \\forall i \\in \\{1, \\dots, \\lfloor n/2 \\rfloor\\}\n$$  \nLet $ D = \\{ |a_i - a_{n+1-i}| \\mid i = 1, \\dots, \\lfloor n/2 \\rfloor \\} \\setminus \\{0\\} $.  \nThen $ m $ must divide $ \\gcd(D) $ if $ D \\neq \\emptyset $.  \nIf $ D = \\emptyset $, then $ a_i = a_{n+1-i} $ for all $ i $, so the array is already a palindrome, and $ m $ can be arbitrarily large → output $ -1 $.  \nOtherwise, the maximum such $ m $ is $ \\gcd(D) $.","simple_statement":"Given an array of n integers, find the maximum m such that replacing each element with (A_i mod m) makes the array a palindrome. If any m works (i.e., array is already a palindrome), print -1.","has_page_source":false}