#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<math.h>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre(){freopen("c://test//input.in","r",stdin);freopen("c://test//output.out","w",stdout);}
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1,class T2>inline void gmax(T1 &a,T2 b){if(b>a)a=b;}
template <class T1,class T2>inline void gmin(T1 &a,T2 b){if(b<a)a=b;}
const int N=1e6+30,M=0,Z=1e9+7,ms63=1061109567;
int casenum,casei;
int n,x;
int a[N];
int main()
{
while(~scanf("%d",&n))
{
MS(a,0);
int top=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&x);
++a[x];
gmax(top,x);
}
int ans=0;
for(int i=0;i<=top+19;i++)
{
a[i+1]+=a[i]>>1;
ans+=(a[i]&1);
}
printf("%d\n",ans);
}
return 0;
}
/*
【trick&&吐槽】
我们检查合并,最多是会合并的到多19层。
假设top=0,有1e6个2^0,那么就会最终合并到2^19
【题意】
给你n(1<=n<=1e6)个数a[],(0<=a[]<=1e6)。
a[i]表示这个数实际上是2^a[i]。
我们每次取数,可以还没有取的数中任取一些数,
要求这些数的和必须恰好是2^p(0<=p<=inf)。
问你至少要取多少次可以把所有数取完。
【类型】
贪心
【分析】
因为取数涉及到数的合并,数越合并就会变得越大。
所以我们不妨——用从小到大的顺序,进行思考问题。
对于一个现有的2^k,个数a[k]为num个,如果num为奇数,那这些数就一定要单独取一次。
否则我们一定合并,为什么呢?因为不合并的话,还要再取一次,而且对后面的决策并没有增益。
按照这个原则,一直贪下去,就可以AC啦。
【时间复杂度&&优化】
O(n)
*/