#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef pair<long long,int> PII;
priority_queue<PII> q;
int main()
{
int n;
cin>>n;
long long ans;
for(int i = 1;i <= n;i++)
{
long long high;
scanf("%lld",&high);
if(high!=1) //是1就不进栈
q.push({high,i});
}
//砍竹子
while(!q.empty())
{
long long len = q.top().first;
int num = q.top().second;
long long lenc = sqrt(len/2+1);
q.pop();
if(lenc!=1) q.push({lenc,num});
while(!q.empty() && q.top().first == len && q.top().second == num-1)
//高度相等,先出编号大的
{
num--;
q.pop();
if(lenc != 1)
{
q.push({lenc,num}); //num为最大编号的那位编号,所以他后面的就要减1
}
}
ans ++;
}
printf("%lld",ans);
return 0;
}
pair数据 是 {}
优先数组: priority_queue 先出最大的项
定义queue的数据类型: queue<xx>
typedef pair <xx,xx> xx;