{"problem":{"name":"I. Abu Tahun Mod problem","description":{"content":"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","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10203I"},"statements":[{"statement_type":"Markdown","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## Input\n\nThe 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)$\n\n## Output\n\nPrint the maximum value of $m$ Abu Tahun can choose, if $m$ is arbitrarily large print -1.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**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) $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10203I","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}