atcoder#ABC272G. [ABC272G] Yet Another mod M
[ABC272G] Yet Another mod M
Score : points
Problem Statement
You are given a sequence of length consisting of positive integers, where the elements of are distinct.
You will choose a positive integer between and (inclusive) to perform the following operation once:
- For each integer such that , replace with .
Can you choose an so that satisfies the following condition after the operation? If you can, find such an .
- There exists an integer such that is the majority in .
Here, an integer is said to be the majority in if the number of integers such that is greater than the number of integers such that .
Constraints
- The elements of are distinct.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
If there exists an that satisfies the condition, print such an . Otherwise, print .
5
3 17 8 14 10
7
If you let to perform the operation, you will have , where is the majority in , so satisfies the condition.
10
822848257 553915718 220834133 692082894 567771297 176423255 25919724 849988238 85134228 235637759
37
10
1 2 3 4 5 6 7 8 9 10
-1