T580950 「2025 扬大ACM选拔赛」B - Magic Coins
题目描述
MilkDragon recently discovered an amazing secret while working at a magic shop—coins can be upgraded through a "Double Synthesis Spell"! Whenever two coins of the same value gently collide, they emit a "ding" sound and merge into a single coin of higher value. Looking at the pile of coins in his hands, MilkDragon decided to use this magic to create a super valuable coin!
Milk Dragon has $n$ magic coins, each of which has a different magic level. The rules are as follows:
- The $i$-th coin has a magic level of $a_i$.
- Two coins with the same magic level of $j$ can be combined into one coin with a magic level of $j+1$.
- The coins after synthesis can continue to participate in higher level synthesis
Could you please help Milk Dragon calculate the **maximum magic level $k$** that these coins will eventually reach through repeated use of the Double Synthesis Spell.
输入格式
First line, $n$ ($1\le n\le 10^6$) positive integers.
Second line, $n$ non-negative integers $a_1,\cdots,a_n$
($0\le a_i\le 201720$).
输出格式
Output a non-negative integer $k$, representing the maximum magic level.