#P11804. Coin Merging

    ID: 13902 Type: Default 1000ms 256MiB

Coin Merging

Coin Merging

Given \(n\) coins where the \(i\)th coin has a denomination \(2^{a_i}\). You can merge two coins of equal denomination \(2^j\) to form a single coin of denomination \(2^{j+1}\). Determine the maximum coin denomination that can be obtained by performing zero or more merge operations.

Note: The final result should be output as \(2^j\) for some integer \(j\).

inputFormat

The first line contains a single integer \(n\) (\(1 \leq n \leq 10^5\)), representing the number of coins.

The second line contains \(n\) integers \(a_1, a_2, \dots, a_n\) (\(0 \leq a_i \leq 10^9\)), where the value of the \(i\)th coin is \(2^{a_i}\).

outputFormat

Output a single integer representing the maximum coin denomination (i.e., \(2^j\)) obtainable after performing any valid sequence of merge operations.

sample

3
1 1 1
4