시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 (추가 시간 없음) | 1024 MB | 23 | 7 | 7 | 35.000% |
Given $n$ integers $a_1, a_2, \ldots, a_n$, you want to perform the following operation exactly $n-1$ times.
Since this alone is just too boring, you can additionally choose a number and add one to it at any moment. You must perform the add-one operation exactly once.
Eventually, only one number will be left in this sequence, and you need to maximize this remaining number. Print the maximum value of the remaining number.
The first line of the input contains a single integer $n$ ($1 \le n \le 10^6$).
The next line of the input contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i < 2^{60}$).
Output a single line containing a single integer: the maximum value of the remaining number.
4 1 2 1 2
7
5 1 2 3 4 5
14
6 1 2 4 7 15 31
47
In the first example, the optimal strategy is: