{"problem":{"name":"Yet Another mod M","description":{"content":"You are given a sequence $A=(A_1,A_2,\\dots,A_N)$ of length $N$ consisting of positive integers, where the elements of $A$ are distinct. You will choose a positive integer $M$ between $3$ and $10^9$ (i","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc272_g"},"statements":[{"statement_type":"Markdown","content":"You are given a sequence $A=(A_1,A_2,\\dots,A_N)$ of length $N$ consisting of positive integers, where the elements of $A$ are distinct.\nYou will choose a positive integer $M$ between $3$ and $10^9$ (inclusive) to perform the following operation once:\n\n*   For each integer $i$ such that $1 \\le i \\le N$, replace $A_i$ with $A_i \\bmod M$.\n\nCan you choose an $M$ so that $A$ satisfies the following condition after the operation? If you can, find such an $M$.\n\n*   There exists an integer $x$ such that $x$ is the majority in $A$.\n\nHere, an integer $x$ is said to be the majority in $A$ if the number of integers $i$ such that $A_i = x$ is greater than the number of integers $i$ such that $A_i \\neq x$.\n\n## Constraints\n\n*   $3 \\le N \\le 5000$\n*   $1 \\le A_i \\le 10^9$\n*   The elements of $A$ are distinct.\n*   All values in the input are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\dots$ $A_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc272_g","tags":[],"sample_group":[["5\n3 17 8 14 10","7\n\nIf you let $M=7$ to perform the operation, you will have $A=(3,3,1,0,3)$, where $3$ is the majority in $A$, so $M=7$ satisfies the condition."],["10\n822848257 553915718 220834133 692082894 567771297 176423255 25919724 849988238 85134228 235637759","37"],["10\n1 2 3 4 5 6 7 8 9 10","\\-1"]],"created_at":"2026-03-03 11:01:14"}}