Pyramid
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Zenyk has \(n\) sticks with lengths \(a_i\).
We will consider that \(k\) sticks with lengths \(x_1\), \(x_2\), ..., \(x_k\) form a pyramid if, by rearranging them, one can obtain a set of \(k\) sticks with lengths 1, 3, 5, ..., \(2k - 1\).
The width of a pyramid is defined as the length of its longest stick.
Zenyk can decrease the lengths of arbitrary sticks from the set.
Help Zenyk — tell what is the maximum width of a pyramid that can be obtained using the sticks from the set.
Input
The first line contains an integer \(n\) — the number of sticks in the set.
The second line contains \(n\) integers — the lengths of the sticks in the set.
Output
Print a single integer in one line — the answer to the problem.
Constraints
\(1 \le n \le 10^5\),
\(1 \le a_i \le 10^9\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 6 1 23 4 8 7 3 | 9 |
Notes
Note that Zenyk can use not all sticks to build the pyramid.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|