P7521 [NOI Qualifier Joint Contest 2021 B Paper] Modulo
Description
Given $n$ positive integers $a_i$, please choose three numbers $i, j, k$ ($i \ne j$, $i \ne k$, $j \ne k$) such that the value of $(a_i + a_j) \bmod a_k$ is maximized.
Input Format
The first line contains an integer $n$, indicating the number of integers.
The second line contains $n$ integers, indicating $a_i$.
Output Format
Output one line with one integer, indicating the answer.
Explanation/Hint
For $30\%$ of the testdata, $n \le 100$.
For $60\%$ of the testdata, $n \le 3000$.
For $100\%$ of the testdata, $3 \le n \le 2 \times {10}^5$, $1 \le a_i \le {10}^8$.
Translated by ChatGPT 5