#P5682. [CSP-J 2019 江西] 次大值
[CSP-J 2019 江西] 次大值
Problem Description
Alice has positive integers, numbered from , which are .
Bob has just learned the modulo operation, so he uses these numbers to practice. He wrote down all values of
where denotes the modulo operation.
Alice wants to know the strict second largest value among all results. Deduplicate all values obtained after modulo, meaning that identical results are kept only once. The second largest value among the remaining numbers is called the strict second largest value.
Input Format
The first line contains a positive integer , representing the number of integers.
The second line contains positive integers .
Output Format
Output one integer in a single line, representing the answer.
If there are fewer than two numbers left after deduplicating the modulo results, output .
4
4 5 5 6
4
4
1 1 1 1
-1
7
12 3 8 5 7 20 15
12
Hint
【Constraints】
For of the testdata, ;
For of the testdata, , ;
For of the testdata, , .
【Sample Explanation】
All modulo results are .
After deduplication, we have , so the result is .
Translated by ChatGPT 5