import java.util.*;
import java.io.*;

public class E {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        StringTokenizer st = new StringTokenizer(f.readLine());
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        long sum = 0;
        TreeMap<Pair, Integer> nums = new TreeMap<Pair, Integer>();
        st = new StringTokenizer(f.readLine());
        for(int i = 0; i < n; i++){
            long temp = Long.parseLong(st.nextToken());
            update(nums, new Pair(temp, 1), true);
            sum+=(temp*temp);
        }

        for(int i = n; i < k; i++){
            Pair last = nums.lastKey();
            update(nums, last, false);
            sum-=last.index;
            update(nums, new Pair(last.a, last.b+1), true);
        }

        out.println(sum);
        out.close();

    }
    public static void update(TreeMap<Pair, Integer> map, Pair elem, boolean add){
        if(add){
            if(!map.containsKey(elem)) map.put(elem, 0);
            map.put(elem, map.get(elem)+1);
        }else{
            map.put(elem, map.get(elem)-1);
            if(map.get(elem) == 0) map.remove(elem);
        }
    }
    static class Pair implements Comparable<Pair>{
        public long a;
        public long b;
        public long index;
        public Pair(long a, long b){
            this.a=a;
            this.b=b;
            long val1 = a/b;
            long val2 = a%b;
            long val3 = a/(b+1);
            long val4 = a%(b+1);
            index = ((b-val2)*(val1)*val1 + val2*(val1+1)*(val1+1)) - ((b+1-val4)*(val3)*val3 + val4*(val3+1)*(val3+1));
        }

        public int compareTo(Pair p){
            if(index > p.index) return 1;
            if(index < p.index) return -1;
            if(a < p.a) return -1;
            if(a > p.a) return 1;
            if(b < p.b) return -1;
            if(b > p.b) return 1;
            return 0;
        }
    }
}


import java.util.*;
import java.io.*;

public class E {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        StringTokenizer st = new StringTokenizer(f.readLine());
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        long sum = 0;
        TreeMap<Long, Integer> nums = new TreeMap<Long, Integer>();
        st = new StringTokenizer(f.readLine());
        for(int i = 0; i < n; i++){
            long temp = Long.parseLong(st.nextToken());
            update(nums, temp, true);
        }
        long div = 3;
        int ptr = n;
        if(n == 1){
            div = k-n+1;
            long max = nums.lastKey();
            long a = max/div;
            long b = max%div;
            sum = (div-b)*(a*a) + b*((a+1)*(a+1));
            out.println(sum);
            out.close();
            return;
        }
        while(ptr < k){
            long max = nums.lastKey();
            long smax = max;
            if(nums.get(max) == 1){
                smax = nums.lowerKey(max);
            }
            long osum = max*max;
            while(ptr < k){
                long a = max/div;
                long b = max%div;
                long diff1 = (osum) - ((div-b)*(a*a) + b*((a+1)*(a+1)));
                long a2 = smax/2;
                long b2 = smax%2;
                long diff2 = (smax*smax) - ((2-b2)*(a2*a2) + b2*((a2+1)*(a2+1)));
                if(diff1 > diff2 && ptr != k-1){
                    osum = ((div-b)*(a*a) + b*((a+1)*(a+1)));
                    div++;
                }else{
                    update(nums, max, false);
                    a = max/(div-1);
                    b = max%(div-1);
                    for(int i = 0; i < div-1; i++){
                        if(i < b) update(nums, a+1, true);
                        else update(nums, a, true);
                    }
                    div = 3;
                    ptr++;
                    break;
                }
                ptr++;
            }
        }
        for(long e: nums.keySet()) sum+=(nums.get(e)*(e*e));
        out.println(sum);
        out.close();

    }
    public static void update(TreeMap<Long, Integer> map, long elem, boolean add){
        if(add){
            if(!map.containsKey(elem)) map.put(elem, 0);
            map.put(elem, map.get(elem)+1);
        }else{
            map.put(elem, map.get(elem)-1);
            if(map.get(elem) == 0) map.remove(elem);
        }
    }
}


import java.util.*;
import java.io.*;

public class E {
    public static void main(String[] args) throws IOException{
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        StringTokenizer st = new StringTokenizer(f.readLine());
        int n = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        long sum = 0;
        TreeMap<Long, Integer> nums = new TreeMap<Long, Integer>();
        st = new StringTokenizer(f.readLine());
        for(int i = 0; i < n; i++){
            long temp = Long.parseLong(st.nextToken());
            update(nums, temp, true);
        }
        int div = 3;
        int ptr = n;
        if(n == 1){
            div = k-n+1;
            long max = nums.lastKey();
            long a = max/div;
            long b = max%div;
            sum = (div-b)*(a*a) + b*((a+1)*(a+1));
            out.println(sum);
            out.close();
            return;
        }
        while(ptr < k){
            long max = nums.lastKey();
            long smax = max;
            if(nums.get(max) == 1){
                smax = nums.lowerKey(max);
            }
            long osum = max*max;
            while(ptr < k){
                long a = max/div;
                long b = max%div;
                long diff1 = (osum) - ((div-b)*(a*a) + b*((a+1)*(a+1)));
                long a2 = smax/2;
                long b2 = smax%2;
                long diff2 = (smax*smax) - ((2-b2)*(a2*a2) + b2*((a2+1)*(a2+1)));
                if(diff1 > diff2 && ptr != k-1){
                    osum = ((div-b)*(a*a) + b*((a+1)*(a+1)));
                    div++;
                }else{
                    update(nums, max, false);
                    a = max/(div-1);
                    b = max%(div-1);
                    for(int i = 0; i < div-1; i++){
                        if(i < b) update(nums, a+1, true);
                        else update(nums, a, true);
                    }
                    div = 3;
                    ptr++;
                    break;
                }
                ptr++;
            }
        }
        for(long e: nums.keySet()) sum+=(nums.get(e)*(e*e));
        out.println(sum);
        out.close();

    }
    public static void update(TreeMap<Long, Integer> map, long elem, boolean add){
        if(add){
            if(!map.containsKey(elem)) map.put(elem, 0);
            map.put(elem, map.get(elem)+1);
        }else{
            map.put(elem, map.get(elem)-1);
            if(map.get(elem) == 0) map.remove(elem);
        }
    }
}


#include<bits/stdc++.h>

using namespace std;

const int N = 5e6 + 8;
int cnt[N] , w , n , ans;

int main()
{
	ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	cin >> n;
	for(int i = 0 ; i < n ; i++)
	{
		cin >> w;
		cnt[w]++;
	}
	for(int i = 0 ; i < N ; i++)
	{
		if(cnt[i] % 2)
		{
			cnt[i + 1] += (cnt[i] / 2);
			cnt[i] = 1;
		}
		else
		{
			cnt[i + 1] += (cnt[i] / 2);
			cnt[i] = 0;
		}
	}
	for(int i = 0 ; i < N ; i++)
		ans += cnt[i];
	cout << ans;
}


#include<bits/stdc++.h>

using namespace std;

const int N = 5e6 + 8;
int cnt[N] , w , n , ans;

int main()
{
	ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
	cin >> n;
	for(int i = 0 ; i < n ; i++)
	{
		cin >> w;
		cnt[w]++;
	}
	for(int i = 0 ; i < N ; i++)
	{
		if(cnt[i] % 2)
		{
			cnt[cnt[i] / 2 + i]++;
			cnt[i] = 1;
		}
		else
		{
			cnt[cnt[i] / 2 + i]++;
			cnt[i] = 0;
		}
	}
	for(int i = 0 ; i < N ; i++)
		ans += cnt[i];
	cout << ans;
}


//besmellah
#include<bits/stdc++.h>
using namespace std;

const int M = 1000001;
int a[M + 30];
vector <int> b;

int main(){
    int n, tmp;
    cin >> n;
    b.resize(n);
    cin >> b[0];
    for (int i = 1; i < n; i++){
        cin >> b[i];
    }
    sort(b.begin(), b.end());
    for (int i = 0; i < n; i++){
        a[b[i]] ++;
    }
    tmp = 0;
    for (int i = 0; i < M + 30; i++){
        a[i + 1] += a[i] / 2;
        a[i] %= 2;
        tmp += a[i];
    }
    cout << tmp;
}


//besmellah
#include<bits/stdc++.h>
using namespace std;

const int M = 100001;
int a[M + 30];

int main(){
    int n, tmp;
    cin >> n;
    cin >> tmp;
    a[tmp] ++;
    for (int i = 1; i < n; i++){
        cin >> a[M + 30];
        a[a[M + 30]] ++;
    }
    tmp = 0;
    for (int i = 0; i < M + 30; i++){
        a[i + 1] += a[i] / 2;
        a[i] %= 2;
        tmp += a[i];
    }
    cout << tmp;
}


//besmellah
#include<bits/stdc++.h>
using namespace std;

const int M = 100001;
vector <int> a;

int main(){
    int n, tmp;
    a.resize(M + 30);
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> tmp;
        a[tmp] ++;
    }
    tmp = 0;
    for (int i = 0; i < M + 30; i++){
        a[i + 1] += a[i] / 2;
        a[i] %= 2;
        tmp += a[i];
    }
    cout << tmp;
}


//besmellah
#include<bits/stdc++.h>
using namespace std;

const int M = 1000001;
int a[M + 30];

int main(){
    int n, tmp;
    cin >> n;
    cin >> tmp;
    a[tmp] ++;
    for (int i = 1; i < n; i++){
        cin >> a[M + 30];
        a[a[M + 30]] ++;
    }
    tmp = 0;
    for (int i = 0; i < M + 30; i++){
        a[i + 1] += a[i] / 2;
        a[i] %= 2;
        tmp += a[i];
    }
    cout << tmp;
}


//besmellah
#include<bits/stdc++.h>
using namespace std;

const int M = 1000001;
int a[M + 30];
vector <int> b;

int main(){
    ios::sync_with_stdio(false);
    int n, tmp;
    cin >> n;
    b.resize(n);
    cin >> b[0];
    for (int i = 1; i < n; i++){
        cin >> b[i];
    }
    sort(b.begin(), b.end());
    for (int i = 0; i < n; i++){
        a[b[i]] ++;
    }
    tmp = 0;
    for (int i = 0; i < M + 30; i++){
        a[i + 1] += a[i] / 2;
        a[i] %= 2;
        tmp += a[i];
    }
    cout << tmp;
}


#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define F first
#define S second
#define debug(x) cour<<#x<<" :"<<x<<"\n"
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define FAST ios_base::sync_with_stdio(false), cin.tie(), cout.tie();
#define int long long

typedef long long ll;
typedef long double ld;

const int maxn = 1e6 + 100;
const int mx = 1e6 + 1000;
const int mod = 1e9 + 7;
const int INF = 1e9 + 7;
const int mlog = 20;
const int SQ = 400;

int w[mx];

int32_t main()
{
	FAST;

	int n;
	cin >> n;

	for(int i=1;i<=n;i++)
	{
		int p2;
		cin >> p2;

		w[p2]++;
	}

	for(int i=0;i<maxn;i++)
	{
		w[i+1] += w[i]/2;
		w[i] = (w[i] % 2);
	}

	int ans = 0;
	for(int i=0;i<maxn;i++)
		ans += w[i];

	cout << ans << "\n";

	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define F first
#define S second
#define debug(x) cour<<#x<<" :"<<x<<"\n"
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define FAST ios_base::sync_with_stdio(false), cin.tie(), cout.tie();
#define int long long

typedef long long ll;
typedef long double ld;

const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
const int INF = 1e9 + 7;
const int mlog = 20;
const int SQ = 400;

int w[maxn];

int32_t main()
{
	FAST;

	int n;
	cin >> n;

	for(int i=1;i<=n;i++)
	{
		int p2;
		cin >> p2;

		w[p2]++;
	}

	for(int i=0;i<maxn;i++)
	{
		w[i+1] += w[i]/2;
		w[i] = (w[i] % 2);
	}

	int ans = 0;
	for(int i=0;i<maxn;i++)
		ans += w[i];

	cout << ans << "\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ld long double
#define pb push_back
#define fe first
#define se second
#define nl "\n"
#define pp pair < ll , ll >
#define sz(x) (ll)x.size()
#define st(x) sort(x.begin(),x.end())
#define rst(x) sort(x.rbegin(), x.rend())
#define all(x) x.begin(),x.end()
long double pi = 3.14159265358979323;

const double EPS = 1e-12;
const int N = 1e6 + 100;
const int mod = 1e9 + 7;

ll bit[N] , a[N];

int main()
{
    fast;
    ll n;
    cin >> n ;
    for(int i = 0 ; i < n ;i++ ){
     	cin >> a[i];
     	bit[a[i]]++;
    }
    ll ans = 0 ;
    for(int i = 0 ; i < N - 1 ; i++){
    	ans += bit[i]%2;
    	bit[i+1] += bit[i]/2;
    }
    cout << ans;

    return 0;

}


#include<bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ld long double
#define pb push_back
#define fe first
#define se second
#define nl "\n"
#define pp pair < ll , ll >
#define sz(x) (ll)x.size()
#define st(x) sort(x.begin(),x.end())
#define rst(x) sort(x.rbegin(), x.rend())
#define all(x) x.begin(),x.end()
long double pi = 3.14159265358979323;

const double EPS = 1e-12;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;

ll bit[N] , a[N];

int main()
{
    fast;
    ll n;
    cin >> n ;
    for(int i = 0 ; i < n ;i++ ){
     	cin >> a[i];
     	bit[a[i]]++;
    }
    ll ans = 0 ;
    for(int i = 0 ; i < N ; i++){
    	ans += bit[i]%2;
    	bit[i+1] += bit[i]/2;
    }
    cout << ans;

    return 0;

}


#include<bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ld long double
#define pb push_back
#define fe first
#define se second
#define nl "\n"
#define pp pair < ll , ll >
#define sz(x) (ll)x.size()
#define st(x) sort(x.begin(),x.end())
#define rst(x) sort(x.rbegin(), x.rend())
#define all(x) x.begin(),x.end()
long double pi = 3.14159265358979323;

const double EPS = 1e-12;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;

ll bit[N] , a[N];

int main()
{
    fast;
    ll n;
    cin >> n ;
    for(int i = 0 ; i < n ;i++ ){
     	cin >> a[i];
     	bit[a[i]]++;
    }
    ll ans = 0 ;
    for(int i = 0 ; i < N - 1 ; i++){
    	ans += bit[i]%2;
    	bit[i+1] += bit[i]/2;
    }
    cout << ans;

    return 0;

}


#include<bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ld long double
#define pb push_back
#define fe first
#define se second
#define nl "\n"
#define pp pair < ll , ll >
#define sz(x) (ll)x.size()
#define st(x) sort(x.begin(),x.end())
#define rst(x) sort(x.rbegin(), x.rend())
#define all(x) x.begin(),x.end()
long double pi = 3.14159265358979323;

const double EPS = 1e-12;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;

int main()
{
    fast;
    ll n;
    cin >> n ;
    ll a[n];
    for(int i = 0 ; i < n ;i++ ){
     	cin >> a[i];
    }
    ll ans = 1;
    ll pos = a[0];
    for(int i = 1 ; i < n ;i++ ){
    	if(a[i] == pos){
    		pos++;
    	}
    	else
    		ans++;
    }
    cout << ans;

    return 0;

}


#include<bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ld long double
#define pb push_back
#define fe first
#define se second
#define nl "\n"
#define pp pair < ll , ll >
#define sz(x) (ll)x.size()
#define st(x) sort(x.begin(),x.end())
#define rst(x) sort(x.rbegin(), x.rend())
#define all(x) x.begin(),x.end()
long double pi = 3.14159265358979323;

const double EPS = 1e-12;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;

int main()
{
    fast;
    ll n;
    cin >> n ;
    ll a[n];
    for(int i = 0 ; i < n ;i++ ){
     	cin >> a[i];
    }
    sort(a , a + n);
    ll ans = 1;
    ll pos = a[0];
    for(int i = 1 ; i < n ;i++ ){
    	if(a[i] == pos){
    		pos++;
    	}
    	else{
    		pos = max(pos , a[i]);
    		ans++;
    	}
    }
    cout << ans;

    return 0;

}


#include <bits/stdc++.h>
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
const int MOD=1e9+7;
long long int n,m,answer=0,calc;
long long int deg[200005];
long long int visited[200005],arp[200005],bd[200005],sz[200005];
vector<long long int > comp,like[200005],dislike[200005];
void dfs(long long int v)
{
    arp[v]=calc;
    sz[calc]++;
    for(auto it: like[v])
    {
        if(arp[it]==0)
            dfs(it);
    }

}
long long int count3(long long int a)
{
    long long int ans=0;
    while(a%3==0)
    {
        ans++;
        a/=3;
    }
    return ans;
}
long long int power(long long int a,long long int b, int m)
{
    long long int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a)%m;

        }
        b=b/2;
        a=(a*a)%m;
    }
    return ans;
}
long long int addd(long long int a,long long int b)
{
    long long int ans=0;
    if(a==1&&b==1)
        ans=2;
    if(a==2&&b==1)
        ans=1;
    if(a==1&&b==2)
        ans=1;
    if(a==2&&b==2)
        ans=1;
    return ans;
}

int main()
    {

            fast();
            long long int a=0,b=0,c=0,e=0,f=0,t=1,type,sum1=0,sum2=0,sum=0,flag=0,mini=0,pos=0,add=0,count=0,a1=0,b1=0,c1=0,end=0,index=0;
            long long int h,k,i,j,p,q,ql,qr,r,l,u,v,x,y,z,x1,x2,y1,y2,cur,gcdc,centre=0,maxi=0,med=0,start=0,ans=0,mid=0,lo=0,hi=0,rem=0,one,low=0,high=0;
            string s,s1,s2,s3,s4,s5,s6,s7,s8,s9;
            bool aa=false,bb=false;
            //double e=0,f,tot,fav,ans=1,sum1=0,sum2=0;
            //int a=0,b=0,c=0,d=0;
            //long double xx,yy,r;
            //cin>>t;
            while(t--)
            {
                cin>>n;
                //vector<long long int> a;
                //vector<long long int> :: iterator it,ls;
                //a.push_back(0);
                //pair<long long int ,long long int > ar[n];
                long long int a[n]={0};
                //set<long long int> s;
                //set<long long int>:: iterator it;
                //cin>>a[0];
                //b=a[0];
                //vector<pair<int,int>>ar;
                //string ss[n+1];
                //long long int in[1005]={0},ouy[1005]={0},d[1005]={0};
                long long int tot=0;
                for(i=0;i<n;i++)
                {
                    cin>>a[i];
                    tot+=pow(2,a[i]);

                }
                if(n==1)
                {
                    cout<<0;
                    return 0;
                }
                c=__builtin_popcount(tot);
                cout<<c;

            }

              return 0;
    }


#include <bits/stdc++.h>
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
const int MOD=1e9+7;
long long int n,m,answer=0,calc;
long long int deg[200005];
long long int visited[200005],arp[200005],bd[200005],sz[200005];
vector<long long int > comp,like[200005],dislike[200005];
void dfs(long long int v)
{
    arp[v]=calc;
    sz[calc]++;
    for(auto it: like[v])
    {
        if(arp[it]==0)
            dfs(it);
    }

}
long long int count3(long long int a)
{
    long long int ans=0;
    while(a%3==0)
    {
        ans++;
        a/=3;
    }
    return ans;
}
long long int power(long long int a,long long int b, int m)
{
    long long int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a)%m;

        }
        b=b/2;
        a=(a*a)%m;
    }
    return ans;
}
long long int addd(long long int a,long long int b)
{
    long long int ans=0;
    if(a==1&&b==1)
        ans=2;
    if(a==2&&b==1)
        ans=1;
    if(a==1&&b==2)
        ans=1;
    if(a==2&&b==2)
        ans=1;
    return ans;
}

int main()
    {

            fast();
            long long int a=0,b=0,c=0,e=0,f=0,t=1,type,sum1=0,sum2=0,sum=0,flag=0,mini=0,pos=0,add=0,count=0,a1=0,b1=0,c1=0,end=0,index=0;
            long long int h,k,i,j,p,q,ql,qr,r,l,u,v,x,y,z,x1,x2,y1,y2,cur,gcdc,centre=0,maxi=0,med=0,start=0,ans=0,mid=0,lo=0,hi=0,rem=0,one,low=0,high=0;
            string s,s1,s2,s3,s4,s5,s6,s7,s8,s9;
            bool aa=false,bb=false;
            //double e=0,f,tot,fav,ans=1,sum1=0,sum2=0;
            //int a=0,b=0,c=0,d=0;
            //long double xx,yy,r;
            //cin>>t;
            while(t--)
            {
                cin>>n;
                //vector<long long int> a;
                //vector<long long int> :: iterator it,ls;
                //a.push_back(0);
                //pair<long long int ,long long int > ar[n];
                long long int a[n]={0};
                //set<long long int> s;
                //set<long long int>:: iterator it;
                //cin>>a[0];
                //b=a[0];
                //vector<pair<int,int>>ar;
                //string ss[n+1];
                //long long int in[1005]={0},ouy[1005]={0},d[1005]={0};
                long long int ar[1000100]={0};
                unsigned long int tot=0;
                for(i=0;i<n;i++)
                {
                    cin>>a[i];
                    //tot+=pow(2,a[i]);
                    ar[a[i]]++;
                }
                ans=0;
                for(i=0;i<1000100;i++)
                {

                    ar[i+1]+=ar[i]/2;
                    ar[i]%=2;
                    ans+=ar[i];

                }
                cout<<ans;

            }

              return 0;
    }


#include <bits/stdc++.h>
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
const int MOD=1e9+7;
long long int n,m,answer=0,calc;
long long int deg[200005];
long long int visited[200005],arp[200005],bd[200005],sz[200005];
vector<long long int > comp,like[200005],dislike[200005];
void dfs(long long int v)
{
    arp[v]=calc;
    sz[calc]++;
    for(auto it: like[v])
    {
        if(arp[it]==0)
            dfs(it);
    }

}
long long int count3(long long int a)
{
    long long int ans=0;
    while(a%3==0)
    {
        ans++;
        a/=3;
    }
    return ans;
}
long long int power(long long int a,long long int b, int m)
{
    long long int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a)%m;

        }
        b=b/2;
        a=(a*a)%m;
    }
    return ans;
}
long long int addd(long long int a,long long int b)
{
    long long int ans=0;
    if(a==1&&b==1)
        ans=2;
    if(a==2&&b==1)
        ans=1;
    if(a==1&&b==2)
        ans=1;
    if(a==2&&b==2)
        ans=1;
    return ans;
}

int main()
    {

            fast();
            long long int a=0,b=0,c=0,e=0,f=0,t=1,type,sum1=0,sum2=0,sum=0,flag=0,mini=0,pos=0,add=0,count=0,a1=0,b1=0,c1=0,end=0,index=0;
            long long int h,k,i,j,p,q,ql,qr,r,l,u,v,x,y,z,x1,x2,y1,y2,cur,gcdc,centre=0,maxi=0,med=0,start=0,ans=0,mid=0,lo=0,hi=0,rem=0,one,low=0,high=0;
            string s,s1,s2,s3,s4,s5,s6,s7,s8,s9;
            bool aa=false,bb=false;
            //double e=0,f,tot,fav,ans=1,sum1=0,sum2=0;
            //int a=0,b=0,c=0,d=0;
            //long double xx,yy,r;
            //cin>>t;
            while(t--)
            {
                cin>>n;
                //vector<long long int> a;
                //vector<long long int> :: iterator it,ls;
                //a.push_back(0);
                //pair<long long int ,long long int > ar[n];
                long long int a[n]={0};
                //set<long long int> s;
                //set<long long int>:: iterator it;
                //cin>>a[0];
                //b=a[0];
                //vector<pair<int,int>>ar;
                //string ss[n+1];
                //long long int in[1005]={0},ouy[1005]={0},d[1005]={0};
                long long int tot=0;
                for(i=0;i<n;i++)
                {
                    cin>>a[i];
                    tot+=pow(2,a[i]);

                }
                c=__builtin_popcount(tot);
                cout<<c;

            }

              return 0;
    }


#include <bits/stdc++.h>
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
const int MOD=1e9+7;
long long int n,m,answer=0,calc;
long long int deg[200005];
long long int visited[200005],arp[200005],bd[200005],sz[200005];
vector<long long int > comp,like[200005],dislike[200005];
void dfs(long long int v)
{
    arp[v]=calc;
    sz[calc]++;
    for(auto it: like[v])
    {
        if(arp[it]==0)
            dfs(it);
    }

}
long long int count3(long long int a)
{
    long long int ans=0;
    while(a%3==0)
    {
        ans++;
        a/=3;
    }
    return ans;
}
long long int power(long long int a,long long int b, int m)
{
    long long int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a)%m;

        }
        b=b/2;
        a=(a*a)%m;
    }
    return ans;
}
long long int addd(long long int a,long long int b)
{
    long long int ans=0;
    if(a==1&&b==1)
        ans=2;
    if(a==2&&b==1)
        ans=1;
    if(a==1&&b==2)
        ans=1;
    if(a==2&&b==2)
        ans=1;
    return ans;
}

int main()
    {

            fast();
            long long int a=0,b=0,c=0,e=0,f=0,t=1,type,sum1=0,sum2=0,sum=0,flag=0,mini=0,pos=0,add=0,count=0,a1=0,b1=0,c1=0,end=0,index=0;
            long long int h,k,i,j,p,q,ql,qr,r,l,u,v,x,y,z,x1,x2,y1,y2,cur,gcdc,centre=0,maxi=0,med=0,start=0,ans=0,mid=0,lo=0,hi=0,rem=0,one,low=0,high=0;
            string s,s1,s2,s3,s4,s5,s6,s7,s8,s9;
            bool aa=false,bb=false;
            //double e=0,f,tot,fav,ans=1,sum1=0,sum2=0;
            //int a=0,b=0,c=0,d=0;
            //long double xx,yy,r;
            //cin>>t;
            while(t--)
            {
                cin>>n;
                //vector<long long int> a;
                //vector<long long int> :: iterator it,ls;
                //a.push_back(0);
                //pair<long long int ,long long int > ar[n];
                long long int a[n]={0};
                //set<long long int> s;
                //set<long long int>:: iterator it;
                //cin>>a[0];
                //b=a[0];
                //vector<pair<int,int>>ar;
                //string ss[n+1];
                //long long int in[1005]={0},ouy[1005]={0},d[1005]={0};
                long long int ar[1000100]={0};
                unsigned long int tot=0;
                for(i=0;i<n;i++)
                {
                    cin>>a[i];
                    //tot+=pow(2,a[i]);
                    ar[a[i]]++;
                }
                ans=0;
                for(i=0;i<1000100;i++)
                {
                    a[i+1]+=a[i]/2;
                    a[i]%=2;
                    ans+=a[i];

                }
                cout<<ans;

            }

              return 0;
    }


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))
int main()
{
    FAST;
   ll n;
   cin>>n;
   ll x;
   ll y[5000005];
   memset(y,0,sizeof(y));
   for(ll i=0;i<n;i++)
   {
       cin>>x;
       y[x]++;
   }
   for(ll i=0;i<5000000;i++)
   {
       if(y[i]>=2)
       {
           ll temp = i;
           if(y[i]%2==0)
           {
               y[temp+1] += y[i]/2;
               y[temp] = 0;
           }
           else
           {
               y[temp+1] += y[i]/2;
               y[temp] = 1;
           }
       }
   }
   ll ans = 0;
   for(ll i=0;i<5000000;i++)
   {
       if(y[i]==1)  ans++;
   }
   cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll n;
   cin>>n;
   ll x;
   ll y[1000001];
   memset(y,0,sizeof(y));
   for(ll i=0;i<n;i++)
   {
       cin>>x;
       y[x]++;
   }
   for(ll i=0;i<1000001;i++)
   {
       if(y[i]>=2)
       {
           ll temp = i;
           if(y[i]%2==0)
           {
               y[temp+1] += y[i]/2;
               y[temp] = 0;
           }
           else
           {
               y[temp+1] += y[i]/2;
               y[temp] = 1;
           }
       }
   }
   ll ans = 0;
   for(ll i=0;i<1000001;i++)
   {
       if(y[i]==1)  ans++;
   }
   cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll n;
   cin>>n;
   ll x;
   map<ll,ll> y;
   for(ll i=0;i<n;i++)
   {
       cin>>x;
       y[x]++;
   }
   for(auto X:y)
   {
       if(X.second>=2)
       {
           ll temp = X.first;
           if(X.second%2==0)
           {
               y[temp+1] += X.second/2;
               y[temp] = 0;
           }
           else
           {
               y[temp+1] += X.second/2;
               y[temp] = 1;
           }
       }
   }
   ll ans = 0;
   for(auto X:y)
   {
       if(X.second==1)  ans++;
   }
   cout<<ans;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))
int main()
{
    FAST;
   ll n;
   cin>>n;
   ll x;
   ll y[1000001];
   memset(y,0,sizeof(y));
   for(ll i=0;i<n;i++)
   {
       cin>>x;
       y[x]++;
   }
   for(ll i=0;i<1000001;i++)
   {
       if(y[i]>=2)
       {
           ll temp = i;
           if(y[i]%2==0)
           {
               y[temp+1] += y[i]/2;
               y[temp] = 0;
           }
           else
           {
               y[temp+1] += y[i]/2;
               y[temp] = 1;
           }
       }
   }
   ll ans = 0;
   for(ll i=0;i<1000001;i++)
   {
       if(y[i]==1)  ans++;
   }
   cout<<ans;
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef list<int> li;
typedef vector<ll>vl;

#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define FAST     ios_base::sync_with_stdio(false); cin.tie(NULL)
#define print(x){for(auto i:x) cout << i << " "; cout << "\n";}

const ll INF64=1e18;
const int INF=1e9;
const ld PI=acos(-1);//3.1415926535897932384626433

template<typename T>
void read(vector<T>& v){
    int n=v.size();
    for(int i=0; i<n; i++)
        cin >> v[i];
}
ll ceil(ll a,ll b){
    ll ans=a/b;
    if(a%b)ans++;
    return ans;
}
ld log (ld a,ld b){return log(b)/log(a);}
ll power(ll base, ll exp,ll M=LLONG_MAX){//(base^exp)%M
    ll res=1;
    while(exp){
        if(exp%2==1)res=((res%M)*(base%M))%M;
        base=((base%M)*(base%M))%M;
        exp/=2;
    }
    return res;
}
string to_base(int n,int new_base){
    string s;
    int nn=n;
    while(nn){
        s+=to_string(nn%new_base);
        nn/=new_base;
    }
    reverse(all(s));
    return s;
}
ll gcd(ll a,ll b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll x= (a/gcd(a,b));
    return b*x;
}
vector<bool>sieve(int n){
    vector<bool>ans(n+1);
    for(int i=2; i<=n; i++)
        ans[i]=1;
    for(int i=2; i*i<=n; i++){
        if(ans[i])
            for(int j=2*i; j<=n; j+=i)
                ans[j]=0;
    }
    return ans;
}
void solve();

int main() {
    FAST;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}
bool ok(ll n){
    for(ll i=2; i*i<=n; i++)
        if(n%(i*i)==0)return 0;
    return 1;

}
void solve() {
    int n;
    cin >> n;
    vi a(n);
    read(a);
    vi cnt(5e6);
    int ans=0;
    for(int i=0; i<n; i++)
        cnt[a[i]]++;
    for(int i=0; i<cnt.size()-1; i++) {
        cnt[i+1]+=(cnt[i]/2);
        cnt[i]%=2;
    }
    for(int i=0 ; i<cnt.size(); i++)
        if(cnt[i])
            ans++;
    out(ans)
}


#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef list<int> li;
typedef vector<ll>vl;

#define all(x) x.begin(),x.end()
#define YES out("YES")
#define NO out("NO")
#define out(x){cout << x << "\n"; return;}
#define FAST     ios_base::sync_with_stdio(false); cin.tie(NULL)
#define print(x){for(auto i:x) cout << i << " "; cout << "\n";}

const ll INF64=1e18;
const int INF=1e9;
const ld PI=acos(-1);//3.1415926535897932384626433

template<typename T>
void read(vector<T>& v){
    int n=v.size();
    for(int i=0; i<n; i++)
        cin >> v[i];
}
ll ceil(ll a,ll b){
    ll ans=a/b;
    if(a%b)ans++;
    return ans;
}
ld log (ld a,ld b){return log(b)/log(a);}
ll power(ll base, ll exp,ll M=LLONG_MAX){//(base^exp)%M
    ll res=1;
    while(exp){
        if(exp%2==1)res=((res%M)*(base%M))%M;
        base=((base%M)*(base%M))%M;
        exp/=2;
    }
    return res;
}
string to_base(int n,int new_base){
    string s;
    int nn=n;
    while(nn){
        s+=to_string(nn%new_base);
        nn/=new_base;
    }
    reverse(all(s));
    return s;
}
ll gcd(ll a,ll b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll x= (a/gcd(a,b));
    return b*x;
}
vector<bool>sieve(int n){
    vector<bool>ans(n+1);
    for(int i=2; i<=n; i++)
        ans[i]=1;
    for(int i=2; i*i<=n; i++){
        if(ans[i])
            for(int j=2*i; j<=n; j+=i)
                ans[j]=0;
    }
    return ans;
}
void solve();

int main() {
    FAST;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}
bool ok(ll n){
    for(ll i=2; i*i<=n; i++)
        if(n%(i*i)==0)return 0;
    return 1;

}
void solve() {
    int n;
    cin >> n;
    vi a(n);
    read(a);
    vi cnt(1e6+1);
    int ans=0;
    map<int,int>cnt2;
    for(int i=0; i<n; i++){
        cnt[a[i]]++;
    }
    for(int i=0; i<cnt.size(); i++) {
        if (cnt[i] > 1) {
            cnt[i + 1] = cnt[i] / 2 + cnt[i] % 2;
            cnt[i]%=2;
        }
    }
    for(int i=0 ; i<cnt.size(); i++)
        if(cnt[i])
            ans++;
    out(ans)
}


// Author : Het Pandya  @hetpandya98
/*
If it doesn't burn a little then what's
the point of playing with fire?
*/

#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define MOD 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define POPB  pop_back
#define TR(v,it) for(auto it=v.begin();it!=v.end();it++)
#define FT(i,n) for(int i=0;i<n;i++)
#define FRT(i,n) for(int i=n-1;i>=0;i--)
#define FTG(i,a,b) for(int i=a;i<=b;i++)
#define FTGR(i,a,b) for(int i=a;i>=b;i--)
#define SORTALL(v) sort(v.begin(),v.end())
#define SORTALLG(v) sort(v.begin(),v.end(),greater<>())
#define MP make_pair
#define F first
#define S second

void shoot(){
    #ifndef ONLINE_JUDGE
    freopen ("input.txt","r",stdin);
    freopen ("output.txt","w",stdout);
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #endif
}

// int Find(int node) {
//   if(parent[node] != node) {
//       parent[node] = Find(parent[node]);
//   }
//   return parent[node];
// }

// void Union(int a, int b) {
//   int parent1, parent2;
//   parent1 = Find(a);
//   parent2 = Find(b);
//   if(parent1 != parent2)
//       parent[parent1] = parent2;
//   //or parent[parent2] = parent1
// }

ll power(ll n,ll pwr){
  ll ans=1LL;
  while(pwr){
      if(pwr&1)
      ans=(ans*n)%MOD;
      n=(n*n)%MOD;
      pwr>>=1;
  }
  return ans;
}

// vector <ll> pr;
// bool prime[100001];
// void BuildSieve(){
//     memset(prime, true, sizeof(prime));
//     prime[1]=false;
//     for (int p=2; p*p<=100001; p++){
//         if (prime[p] == true){
//           pr.PB(p);
//             for (int i=p*2; i<=100001; i += p)
//                 prime[i] = false;
//         }
//     }
// }

// ll bigmod(ll num,ll n){
//   if(n==0) return 1;
//   ll x=bigmod(num,n/2);
//   x=x*x%MOD;
//   if(n%2==1) x=x*num%MOD;
//   return x;
// }

// ll modinverse(ll num){
//   return bigmod(num,MOD-2)%MOD;
// }

// ll gcd(ll a, ll b){
//     if (a == 0)
//         return b;
//     return gcd(b%a, a);
// }

// bool isPowerOfTwo (ll x){
//   return x && (!(x&(x-1)));
// }

int main(){
  shoot();
  ll i,n,x,ans=0;
  cin>>n;
  ll a[1000003];
  memset(a,0,sizeof(a));
  for(i=0;i<n;i++){
    cin>>x;
    a[x]++;
  }
  for(i=0;i<=1000001;i++){
      if(a[i]%2==1){
        a[i+1]+=a[i]/2;
        a[i]=1;
      }
      else{
        a[i+1]+=a[i]/2;
        a[i]=0;
      }
  }
  for(i=0;i<=1000001;i++){
    if(a[i]!=0) ans++;
  }
  cout<<ans;

    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}


// Author : Het Pandya  @hetpandya98
/*
If it doesn't burn a little then what's
the point of playing with fire?
*/

#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define MOD 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define POPB  pop_back
#define TR(v,it) for(auto it=v.begin();it!=v.end();it++)
#define FT(i,n) for(int i=0;i<n;i++)
#define FRT(i,n) for(int i=n-1;i>=0;i--)
#define FTG(i,a,b) for(int i=a;i<=b;i++)
#define FTGR(i,a,b) for(int i=a;i>=b;i--)
#define SORTALL(v) sort(v.begin(),v.end())
#define SORTALLG(v) sort(v.begin(),v.end(),greater<>())
#define MP make_pair
#define F first
#define S second

void shoot(){
    #ifndef ONLINE_JUDGE
    freopen ("input.txt","r",stdin);
    freopen ("output.txt","w",stdout);
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #endif
}

// int Find(int node) {
//   if(parent[node] != node) {
//       parent[node] = Find(parent[node]);
//   }
//   return parent[node];
// }

// void Union(int a, int b) {
//   int parent1, parent2;
//   parent1 = Find(a);
//   parent2 = Find(b);
//   if(parent1 != parent2)
//       parent[parent1] = parent2;
//   //or parent[parent2] = parent1
// }

ll power(ll n,ll pwr){
  ll ans=1LL;
  while(pwr){
      if(pwr&1)
      ans=(ans*n)%MOD;
      n=(n*n)%MOD;
      pwr>>=1;
  }
  return ans;
}

// vector <ll> pr;
// bool prime[100001];
// void BuildSieve(){
//     memset(prime, true, sizeof(prime));
//     prime[1]=false;
//     for (int p=2; p*p<=100001; p++){
//         if (prime[p] == true){
//           pr.PB(p);
//             for (int i=p*2; i<=100001; i += p)
//                 prime[i] = false;
//         }
//     }
// }

// ll bigmod(ll num,ll n){
//   if(n==0) return 1;
//   ll x=bigmod(num,n/2);
//   x=x*x%MOD;
//   if(n%2==1) x=x*num%MOD;
//   return x;
// }

// ll modinverse(ll num){
//   return bigmod(num,MOD-2)%MOD;
// }

// ll gcd(ll a, ll b){
//     if (a == 0)
//         return b;
//     return gcd(b%a, a);
// }

// bool isPowerOfTwo (ll x){
//   return x && (!(x&(x-1)));
// }

int main(){
  shoot();
  ll i,n,x,ans=0;
  cin>>n;
  ll a[2000003];
  memset(a,0,sizeof(a));
  for(i=0;i<n;i++){
    cin>>x;
    a[x]++;
  }
  for(i=0;i<=2000001;i++){
      if(a[i]%2==1){
        a[i+1]+=a[i]/2;
        a[i]=1;
      }
      else{
        a[i+1]+=a[i]/2;
        a[i]=0;
      }
  }
  for(i=0;i<=2000001;i++){
    if(a[i]!=0) ans++;
  }
  cout<<ans;

    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int fre[2000001];
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));
    int n;
    cin >> n;

    int a[n];
    int max1 = INT_MIN;

    int ans = 0;

    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        fre[a[i]]++;
        max1 = max(max1,a[i]);
    }

    for(int i=0;i<2000000;i++)
    {
        if(fre[i]&1)
            ans++;

        fre[i+1] += (fre[i])/2;

        if(i>max1 && fre[i+1]==0)
            break;
    }
    cout << ans << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int fre[2000001]={0};
int main()
{
    int n;
    cin >> n;

    int a[n];
    int max1 = INT_MIN;

    int ans = 0;

    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        fre[a[i]]++;
        max1 = max(max1,a[i]);
    }

    for(int i=0;i<2000000;i++)
    {
        if(fre[i]&1)
            ans++;

        fre[i+1] += (fre[i])/2;

        if(i>max1 && fre[i+1]==0)
            break;
    }
    cout << ans << endl;

    return 0;
}


/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}
#define int long long
const int MAX = 1000100;
int a[MAX];

signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	int x;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		a[x]++;
	}
	int ans=0;
	for(int i=0;i<MAX-1;i++)
	{
		a[i+1]+=a[i]/2;
		a[i]%=2;
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int a[1000005];

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	int x;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		a[x]++;
	}
	int ans=0;
	for(int i=0;i<1000004;i++)
	{
		a[i+1]+=a[i]/2;
		a[i]%=2;
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int a[1000005];

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	int x;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		a[x]++;
	}
	int ans=0;
	for(int i=0;i<1000002;i++)
	{
		a[i+1]+=a[i]/2;
		a[i]%=2;
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}
#define int long long

int a[1000100];

signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	int x;
	for(int i=0;i<n;i++)
	{
		cin>>x;
		a[x]++;
	}
	int ans=0;
	for(int i=0;i<1000100;i++)
	{
		a[i+1]+=a[i]/2;
		a[i]%=2;
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>

using namespace std;

const int N = 1000 * 1000 + 5;
const int M = 1000 * 1000 * 10;
int w[N];
int a[M];
int n;
int ans = 0;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i];
		a[w[i]]++;
	}
	for (int j = 0; j < M; j++)
	{
		a[j + 1] += a[j] / 2;
		a[j] = a[j] % 2;
	}
	for (int j = 0; j < M; j++)
	{
		ans += bool(a[j]);
	}
	cout << ans << endl;

}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>

using namespace std;

const int N = 1000 * 1000 + 5;
const int M = 1000 * 1000 * 10;
int w[N];
int a[M];
int n;
int ans = 0;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> w[i];
		a[w[i]]++;
	}
	for (int j = 0; j < M; j++)
	{
		a[j + 1] += a[j] / 2;
		a[j] = a[j] % 2;
	}
	for (int j = 0; j < M; j++)
	{
		ans += bool(a[j]);
	}
	cout << ans;

}


#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include <map>
#include<iterator>
#include <typeinfo>
#include <string.h>
#include <set>
#include <cstdlib>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double    ld;
typedef pair <ll,ll>  pll;
typedef pair <int,int> pii;
#define rep(h)    for (int i=0; i<h; i++)
#define srep(a,b) for (int i=a; i<b; i++)
#define rrep(a,b) for (int e=a-1; e>=b; e--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"
#define debug(x) cout << x << endl;

  int main()
  {
       ios_base::sync_with_stdio(false);
       cin.tie(NULL); cout.tie(NULL);
     // int t; cin >>t;
    // while(t--)
    {
      int n; cin >>n;
      vector <int> val(n);
      map<int,int> hash;
      rep(n) cin >>val[i],hash[val[i]]++;
      for (auto v:hash) {
       if(v.ss!=0) {hash[v.ff+1]+=v.ss/2; hash[v.ff]=v.ss%2;}
      }
      int ans=0;
      for (auto v:hash) {if(v.ss==1) ans++; }
      cout<<ans<<endl;
    }
  return 0;
  }


#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
#include <map>
#include<iterator>
#include <typeinfo>
#include <string.h>
#include <set>
#include <cstdlib>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double    ld;
typedef pair <ll,ll>  pll;
typedef pair <int,int> pii;
#define rep(h)    for (int i=0; i<h; i++)
#define srep(a,b) for (int i=a; i<b; i++)
#define rrep(a,b) for (int e=a-1; e>=b; e--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"
#define debug(x) cout << x << endl;

  int main()
  {
       ios_base::sync_with_stdio(false);
       cin.tie(NULL); cout.tie(NULL);
     // int t; cin >>t;
    // while(t--)
    {
      int n; cin >>n;
      vector <int> val(n);
      map<int,int> hash;
      rep(n) cin >>val[i],hash[val[i]]++;
      int ans=0;
      for (auto v:hash) {
       if(v.ss!=0) {hash[v.ff+1]+=v.ss/2; ans+=v.ss%2;}
      }
      // for (auto v:hash) {if(v.ss==1) ans++; }
      cout<<ans<<endl;
    }
  return 0;
  }


#include <iostream>
using namespace std;

int main() {
	int t ;
	cin >> t ;
	int x[t+20];
	for(int i = 0 ; i < t+20 ; i++)
		x[i]=0;
	for(int i = 0 ; i < t ; i++)
	{
		int temp ;
		cin >> temp ;
		x[temp]++;
	}
	int sum = 0 ;
	for(int i = 0 ; i < t+20 ; i++)
	{
		x[i+1]+=x[i]/2 ;
		x[i]%=2;
		sum+=x[i];
	}
	cout << sum << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int t ;
	cin >> t ;
	int x[1000004];
	for(int i = 0 ; i < 1000004 ; i++)
		x[i]=0;
	for(int i = 0 ; i < t ; i++)
	{
		int temp ;
		cin >> temp ;
		x[temp]++;
	}
	int sum = 0 ;
	for(int i = 0 ; i < 1000004 ; i++)
	{
		x[i+1]+=x[i]/2 ;
		x[i]%=2;
		sum+=x[i];
	}
	cout << sum << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int t ;
	cin >> t ;
	int x[t+50];
	for(int i = 0 ; i < t+50 ; i++)
		x[i]=0;
	for(int i = 0 ; i < t ; i++)
	{
		int temp ;
		cin >> temp ;
		x[temp]++;
	}
	int sum = 0 ;
	for(int i = 0 ; i < t+50 ; i++)
	{
		x[i+1]+=x[i]/2 ;
		x[i]%=2;
		sum+=x[i];
	}
	cout << sum << endl;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	int t ;
	cin >> t ;
	int x[t+1000];
	for(int i = 0 ; i < t+1000 ; i++)
		x[i]=0;
	for(int i = 0 ; i < t ; i++)
	{
		int temp ;
		cin >> temp ;
		x[temp]++;
	}
	int sum = 0 ;
	for(int i = 0 ; i < t+1000 ; i++)
	{
		x[i+1]+=x[i]/2 ;
		x[i]%=2;
		sum+=x[i];
	}
	cout << sum << endl;
	return 0;
}


#include <iostream>
using namespace std;
int main() {
	int t ;
	cin >> t ;
	int x[1000020];
	for(int i = 0 ; i < 1000020 ; i++)
		x[i]=0 ;
	for(int i = 0 ; i < t ; i++)
	{
		int temp ;
		cin >> temp ;
		x[temp]++ ;
	}
	int sum = 0 ;
	for(int i = 0 ; i < 1000020 ; i++)
	{
		x[i+1]+=(x[i] >> 1) ;
		x[i]= (x[i] & 1) ;
		sum+=x[i] ;
	}
	cout << sum << endl ;
	return 0 ;
}


#include <iostream>
using namespace std;
#define lim 1000020
int main()
{
	ios::sync_with_stdio(false);
	int t ;
	cin >> t ;
	int x[lim];
	for(int i = 0 ; i < lim ; i++)
		x[i]=0;
	for(int i = 0 ; i < t ; i++)
	{
		int temp ;
		cin >> temp ;
		x[temp]++;
	}
	int sum = 0 ;
	for(int i = 0 ; i < lim ; i++)
	{
		x[i+1]+=(x[i] >> 1);
		x[i]= (x[i]&1) ;
	}
	for(int i = 0 ; i < lim ; i++)
		sum+=x[i];
	cout << sum << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define gok ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mo 1000000007
int dp[1000005];
signed main(){
    gok
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++){
    cin>>a[i];
    dp[a[i]]++;
   }
   for(int i=0;i<=1000004;i++)
   {
       int qq = dp[i]/2;
       dp[i+1] += qq;
       dp[i]%=2;
   }
   int an=0;
   for(int i=0;i<=1000004;i++)
   {
      if(dp[i]>1)
      {
          int tt = dp[i];
          while(tt!=0)
          {
              if((tt&1))
              {
                  an++;
              }
              tt/=2;
          }
          break;
      }
      else
      {
          an += dp[i];
      }
   }
   cout<<an;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define gok ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mo 1000000007
int dp[1000005];
signed main(){
    gok
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++){
    cin>>a[i];
    dp[a[i]]++;
   }
   for(int i=0;i<1000004;i++)
   {
       int qq = dp[i]/2;
       dp[i+1] += qq;
       dp[i]%=2;
   }
   int an=0;
   for(int i=0;i<=1000004;i++)
   {
      if(dp[i]>1)
      {
          int tt = dp[i];
          while(tt!=0)
          {
              if((tt%2)==1)
              {
                  an++;
              }
              tt/=2;
          }
          break;
      }
      else
      {
          an += dp[i];
      }
   }
   cout<<an;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define gok ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mo 1000000007
int dp[1000005];
signed main(){
    gok
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++){
    cin>>a[i];
    dp[a[i]]++;
   }
   for(int i=0;i<=1000004;i++)
   {
       int qq = dp[i]/2;
       dp[i+1] += qq;
       dp[i]%=2;
   }
   int an=0;
   for(int i=0;i<1000004;i++)
   {
      if(dp[i]>1)
      {
          int tt = dp[i];
          while(tt!=0)
          {
              if((tt&1))
              {
                  an++;
              }
              tt/=2;
          }
          break;
      }
      else
      {
          an += dp[i];
      }
   }
   cout<<an;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define gok ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mo 1000000007
int dp[1000005];
signed main(){
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++){
    cin>>a[i];
    dp[a[i]]++;
   }
   for(int i=0;i<=1000004;i++)
   {
       int qq = dp[i]/2;
       dp[i+1] += qq;
       dp[i]%=2;
   }
   int an=0;
   for(int i=0;i<1000004;i++)
   {
      if(dp[i]>1)
      {
          int tt = dp[i];
          while(tt!=0)
          {
              if((tt&1))
              {
                  an++;
              }
              tt/=2;
          }
      }
      else
      {
          an += dp[i];
      }
   }
   cout<<an;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

	int n;
	cin >> n;

	int a[1000099]={0};
	for(int i=0; i<n; i++)
	{
		int x;
		cin >> x;
		int a[x]++;
	}
	for(int i=0; i<1000099; i++)
	{
		a[i+1]+=(a[i]/2);
		a[i]=a[i]%2;
	}
	int c=0;
	for(int i=0; i<1000099; i++)
	{
		c+=a[i];

	}

	cout << c;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

	int n;
	cin >> n;

	set<int>s;

	for(int i=0; i<n; i++)
	{
		int x;
		cin >> x;

		while(s.find(x)!=s.end())
		{
			s.erase(x);
			x=x+1;
		} s.insert(x);

	} cout << s.size();

		// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;

	int a[1000030]={0};
	for(int i=0; i<n; i++)
	{
		int x;
		cin >> x;
	    a[x]++;
	}
	for(int i=0; i<1000030; i++)
	{
		a[i+1]+=(a[i]/2);
		a[i]=a[i]%2;
	}
	int c=0;
	for(int i=0; i<1000030; i++)
	{
		c+=a[i];

	}

	cout << c;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

	int n;
	cin >> n;

	int a[1000099]={0};
	for(int i=0; i<n; i++)
	{
		int x;
		cin >> x;
	    a[x]++;
	}
	for(int i=0; i<1000099; i++)
	{
		a[i+1]+=(a[i]/2);
		a[i]=a[i]%2;
	}
	int c=0;
	for(int i=0; i<1000099; i++)
	{
		c+=a[i];

	}

	cout << c;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 2e6+10;

int cnt[N];

int main()
{
	int x,n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		cnt[x]++;
	}

	ll ans = 0;

	for(int i=0;i<N;i++){
		cnt[i+1] += cnt[i]/2;
		ans += (cnt[i]%2);
	}

	cout<<ans;

}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 2e6+10;

int cnt[N];

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int x,n, mx = -1;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		cnt[x]++;
	}

	ll ans = 0;

	for(int i=0;i<N;i++){
		cnt[i+1] += cnt[i]/2;
		ans += (cnt[i]%2);
	}

	cout<<ans;

}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 1e6+10;

int cnt[N];

int main()
{
	int n, mx = -1;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		cnt[x]++;
		mx = max(x,mx);
	}

	ll ans = 0;

	for(int i=0;i<N-1;i++){
		cnt[i+1] += cnt[i]/2;
		ans += (cnt[i]%2);
	}

	cout<<ans;

}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N = 1e6+10;

int cnt[N];

int main()
{
	int n, mx = -1;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		cnt[x]++;
		mx = max(x,mx);
	}

	ll ans = 0;

	for(int i=0;i<mx+5;i++){
		cnt[i+1] += cnt[i]/2;
		ans += (cnt[i]%2);
	}

	cout<<ans;

}


//هوالحق
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000022;
bool A[maxN];

void add(int x){
   if(A[x]){
      A[x] = false;
      add(x+1);
   } else A[x] = true;
}

int main() {
   int n, r = 0;
   cin >> n;
   for(int i = 0; i < n; i++){
      int x;
      cin >> x;
      add(x);
   }
   for(int i : A) if(i) r++;
   cout << r;
   return cout << endl, 0;
}


//هوالحق
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000220;
int A[maxN];

int main() {
   int n, r = 0, mx = 0;
   cin >> n;
   for(int i = 0; i < n; i++){
      int x;
      cin >> x;
      A[x] ++;
      mx = max(x, mx);
   }
   for(int i = 0; i < mx + 22; i++){
      A[i+1] += A[i] / 2;
      A[i] %= 2;
   }
   for(int i : A) r += i;
   cout << r;
   return cout << endl, 0;
}


//هوالحق
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000220;
int A[maxN];

int main() {
   ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
   int n, r = 0, mx = 0;
   cin >> n;
   for(int i = 0; i < n; i++){
      int x;
      cin >> x;
      A[x] ++;
      mx = max(x, mx);
   }
   for(int i = 0; i < mx + 22; i++){
      A[i+1] += A[i] / 2;
      A[i] %= 2;
   }
   for(int i = 0; i < mx + 22; i++) r += A[i];
   cout << r;
   return cout << endl, 0;
}


//هوالحق
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000022;
int A[maxN];

int main() {
   int n, r = 0;
   cin >> n;
   for(int i = 0; i < n; i++){
      int x;
      cin >> x;
      A[x] ++;
   }
   for(int i = 0; i < maxN; i++){
      A[i+1] += A[i] / 2;
      A[i] %= 2;
   }
   for(int i : A) r += i;
   cout << r;
   return cout << endl, 0;
}


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;
const double PI = 3.141592653589793238462643383279502884;
const double esp = 1e-9;

using namespace std;

#ifdef LOCAL_PROJECT
  #define CURTIME()         cerr << el << "[TIME]: " << clock() * 1.0 / CLOCKS_PER_SEC << "s" << el
  #define INFILE(name)      freopen(name, "r", stdin)
  #define OUFILE(name)      freopen(name, "w", stdin)
  #define DEBUG             cerr << "##########\nRunning on Line: " << __LINE__ << "\nIn Function: " <<   __FUNCTION__ << "\n##########\n"
  #define DUMP(value)       cerr << "[" << (#value) << "]: " << (value) << el
#else
  #define CURTIME()         ;
  #define INFILE(name)      ;
  #define OUFILE(name)      ;
  #define DEBUG             ;
  #define DUMP(value)       ;
#endif

#define FASTIO              ios_base::sync_with_stdio(false),cin.tie(NULL)
#define rep(i, a, b)        for(ll i = (a), _b = (b); i <= _b; i++)
#define repv(i, a, b)       for(ll i = (a), _b = (b); i >= _b; i--)
#define repa(i, obj)        for(auto i : obj)
#define mp                  make_pair
#define mt                  make_tuple
#define pb                  push_back
#define fi                  first
#define se                  second
#define lb                  lower_bound
#define ub                  upper_bound
#define prs(n)              cout << fixed << setprecision(n)
#define el                  "\n"
#define sp                  " "
#define ALL(v)              (v).begin(), (v).end()
#define LXCMP(s, t)         lexicographical_compare(ALL(s), ALL(t))  // s > t
#define RALL(v)             (v).rbegin(), (v).rend()
#define MAXVAL(T)           numeric_limits<(T)>::max()
#define INF(T)              numeric_limits<(T)>::infinity()
#define MASK(i)             (1LL << (i))
#define BIT(x, i)           (((x) >> (i)) & 1)
#define div                 ___div
#define next                ___next
#define prev                ___prev
#define left                ___left
#define right               ___right
#define bitcount(n)         __builtin_popcountll(n)

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/**********************************
*  Combination calculate          *
*  Note to self: n >= r           *
*  From N pieces pick R pieces    *
*  The fomular: n! / (r! * (n-r)!)*
*  Complexity: O(r)               *
***********************************/
ll nCr(ll n, ll r){
  ll tmp = n-r;
  for(ll i = n-1; i > tmp; i--)
    n *= i;
  for(ll i = r-1; i > 1; i--)
    r *= i;
  return n/r;
}

/*  CODE BEGIN FROM HERE  */

int main(int argc, char const *argv[]) {
  FASTIO;
  INFILE("in");
  // OUFILE("out");

  ll n;
  cin >> n;
  vector<ll> bitField(n*3, 0);
  ll tmp;
  for(ll i = 0; i < n; i++){
    cin >> tmp;
    bitField[tmp]++;
  }
  ll ans = 0;
  for(ll i = 0; i < n*3; i++){
    if(bitField[i] == 1)
      ans++;
    else if(bitField[i] > 1){
      bitField[i+1] += bitField[i]/2;
      if(bitField[i]%2 != 0)
        ans++;
    }
  }
  cout << ans;
  CURTIME();
  return 0;
}

/******************************
 *         WHITE_FOX          *
 ******************************/


#include <bits/stdc++.h>

typedef int64_t ll;
typedef uint64_t ull;
typedef double db;
const double PI = 3.141592653589793238462643383279502884;
const double esp = 1e-9;

using namespace std;

#ifdef LOCAL_PROJECT
  #define CURTIME()         cerr << el << "[TIME]: " << clock() * 1.0 / CLOCKS_PER_SEC << "s" << el
  #define INFILE(name)      freopen(name, "r", stdin)
  #define OUFILE(name)      freopen(name, "w", stdin)
  #define DEBUG             cerr << "##########\nRunning on Line: " << __LINE__ << "\nIn Function: " <<   __FUNCTION__ << "\n##########\n"
  #define DUMP(value)       cerr << "[" << (#value) << "]: " << (value) << el
#else
  #define CURTIME()         ;
  #define INFILE(name)      ;
  #define OUFILE(name)      ;
  #define DEBUG             ;
  #define DUMP(value)       ;
#endif

#define FASTIO              ios_base::sync_with_stdio(false),cin.tie(NULL)
#define rep(i, a, b)        for(ll i = (a), _b = (b); i <= _b; i++)
#define repv(i, a, b)       for(ll i = (a), _b = (b); i >= _b; i--)
#define repa(i, obj)        for(auto i : obj)
#define mp                  make_pair
#define mt                  make_tuple
#define pb                  push_back
#define fi                  first
#define se                  second
#define lb                  lower_bound
#define ub                  upper_bound
#define prs(n)              cout << fixed << setprecision(n)
#define el                  "\n"
#define sp                  " "
#define ALL(v)              (v).begin(), (v).end()
#define LXCMP(s, t)         lexicographical_compare(ALL(s), ALL(t))  // s > t
#define RALL(v)             (v).rbegin(), (v).rend()
#define MAXVAL(T)           numeric_limits<(T)>::max()
#define INF(T)              numeric_limits<(T)>::infinity()
#define MASK(i)             (1LL << (i))
#define BIT(x, i)           (((x) >> (i)) & 1)
#define div                 ___div
#define next                ___next
#define prev                ___prev
#define left                ___left
#define right               ___right
#define bitcount(n)         __builtin_popcountll(n)

// RNG - for sum fun
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/**********************************
*  Combination calculate          *
*  Note to self: n >= r           *
*  From N pieces pick R pieces    *
*  The fomular: n! / (r! * (n-r)!)*
*  Complexity: O(r)               *
***********************************/
ll nCr(ll n, ll r){
  ll tmp = n-r;
  for(ll i = n-1; i > tmp; i--)
    n *= i;
  for(ll i = r-1; i > 1; i--)
    r *= i;
  return n/r;
}

/*  CODE BEGIN FROM HERE  */
ll const MX = 1000*1000;

int main(int argc, char const *argv[]) {
  FASTIO;
  INFILE("in");
  // OUFILE("out");

  ll n;
  cin >> n;
  vector<ll> bitField(MX*3, 0);
  ll tmp;
  for(ll i = 0; i < n; i++){
    cin >> tmp;
    bitField[tmp]++;
  }
  ll ans = 0;
  for(ll i = 0; i < MX*3; i++){
    if(bitField[i] == 1)
      ans++;
    else if(bitField[i] > 1){
      bitField[i+1] += bitField[i]/2;
      if(bitField[i]%2 != 0)
        ans++;
    }
  }
  cout << ans;
  CURTIME();
  return 0;
}

/******************************
 *         WHITE_FOX          *
 ******************************/


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define sf(n) scanf("%lld",&n)
#define pi acos(-1)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int main()
{
    ll n;
    cin>>n;
    map<ll,ll> m;
    ll high=-1;
    for(int i=0;i<n;i++)
    {
        ll x; sf(x);
        m[x]++;
        if(x>high) high=x;
    }
    ll ans=0;
    for(ll i=0;i<=1000000000;i++)
    {
        ans+=(m[i]%2);
        m[i+1]+=m[i]/2;
        if(i+1>high and m[i+1]==false) break;
    }
    printf("%lld\n",ans);
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define sf(n) scanf("%lld",&n)
#define pi acos(-1)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int main()
{
    int n; cin>>n;
    map<int,int> m;
    for(int i=0;i<n;i++)
    {
        ll x;cin>>x,m[x]++;
    }
    int ans=0;
    for(ll i=0;i<=3000000;i++)
    {
        ans+=m[i]%2;
        m[i+1]+=(m[i]/2);
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define sf(n) scanf("%lld",&n)
#define pi acos(-1)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int main()
{
    ll n;
    cin>>n;
    map<ll,ll> m;
    ll high=-1;
    for(int i=0;i<n;i++)
    {
        ll x; sf(x);
        m[x]++;
        if(x>high) high=x;
    }
    ll ans=0;
    for(ll i=0;i<=1000000000;i++)
    {
        ans+=(m[i]%2);
        m[i+1]+=m[i]/2;
        if(i+1>high and m[i+1]==false) break;
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define sf(n) scanf("%lld",&n)
#define pi acos(-1)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int main()
{
    int n;
    cin>>n;
    map<int,int> m;
    int high=-1;
    for(int i=0;i<n;i++)
    {
        int x; cin>>x;
        m[x]++;
        if(x>high) high=x;
    }
    int ans=0;
    for(ll i=0;i<=10000000000;i++)
    {
        ans+=(m[i]%2);
        m[i+1]+=m[i]/2;
        if(i+1>high and m[i+1]==false) break;
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define sf(n) scanf("%lld",&n)
#define pi acos(-1)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    map<ll,ll> m;
    int high=-1;
    for(int i=0;i<n;i++)
    {
        int x; sf(x);
        m[x]++;
        if(x>high) high=x;
    }
    int ans=0;
    for(ll i=0;i<=10000000000;i++)
    {
        ans+=(m[i]%2);
        m[i+1]+=m[i]/2;
        if(i+1>high and m[i+1]==false) break;
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define sf(n) scanf("%lld",&n)
#define pi acos(-1)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int m[3000000];
int main()
{
    int n; sf(n);

    for(int i=0;i<n;i++)
    {
        ll x;sf(x),m[x]++;
    }
    int ans=0;
    for(ll i=0;i<=3000000;i++)
    {
        ans+=m[i]%2;
        m[i+1]+=(m[i]/2);
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define sf(n) scanf("%lld",&n)
#define pi acos(-1)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int main()
{
    ll n;
    cin>>n;
    map<ll,ll> m;
    ll high=-1;
    for(int i=0;i<n;i++)
    {
        ll x; sf(x);
        m[x]++;
        if(x>high) high=x;
    }
    ll ans=0;
    for(ll i=0;i<=1000000+log(1000000);i++)
    {
        ans+=(m[i]%2);
        m[i+1]+=m[i]/2;
        if(i+1>high and m[i+1]==false) break;
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define sf(n) scanf("%lld",&n)
#define pi acos(-1)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int main()
{
    ll n;
    cin>>n;
    map<int,int > m;
    for(int i=0;i<n;i++)
    {
        ll x; sf(x);
        m[x]++;
    }
    ll ans=0;
    for(int  i=0;i<=30000000;i++)
    {
        ans+=(m[i]%2);
        m[i+1]+=m[i]/2;
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define sf(n) scanf("%lld",&n)
#define pi acos(-1)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int main()
{
    ll n;
    cin>>n;
    map<ll,ll> m;
    for(int i=0;i<n;i++)
    {
        ll x; sf(x);
        m[x]++;
    }
    ll ans=0;
    for(int  i=0;i<=1111111;i++)
    {
        ans+=(m[i]%2);
        m[i+1]+=m[i]/2;
    }
    printf("%lld\n",ans);
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define sf(n) scanf("%lld",&n)
#define pi acos(-1)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int main()
{
    int n;
    cin>>n;
    map<int,int> m;
    int high=-1;
    for(int i=0;i<n;i++)
    {
        int x; cin>>x;
        m[x]++;
        if(x>high) high=x;
    }
    int ans=0;
    for(ll i=1;i<=10000000000;i++)
    {
        ans+=(m[i]%2);
        m[i+1]+=m[i]/2;
        if(i+1>high and m[i+1]==false) break;
    }
    ans+=m[0];
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define sf(n) scanf("%lld",&n)
#define pi acos(-1)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int main()
{
    int n;
    cin>>n;
    map<ll,ll> m;
    int high=-1;
    for(int i=0;i<n;i++)
    {
        int x; sf(x);
        m[x]++;
        if(x>high) high=x;
    }
    int ans=0;
    for(ll i=0;i<=10000000000;i++)
    {
        ans+=(m[i]%2);
        m[i+1]+=m[i]/2;
        if(i+1>high and m[i+1]==false) break;
    }
    cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define sf(n) scanf("%lld",&n)
#define pi acos(-1)
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int main()
{
    int n;
    cin>>n;
    map<ll,ll> m;
    int high=-1;
    for(int i=0;i<n;i++)
    {
        int x; sf(x);
        m[x]++;
        if(x>high) high=x;
    }
    int ans=0;
    for(ll i=0;i<=1000000;i++)
    {
        ans+=(m[i]%2);
        m[i+1]+=m[i]/2;
        if(i+1>high and m[i+1]==false) break;
    }
    cout<<ans<<endl;
}


#pragma GCC optimize("Ofast", "inline", "unroll-loops", "no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int n,inp;
ll c;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n;
    priority_queue<ll> q;
    for(int i=0;i<n;i++){
        cin>>inp; q.push(-inp);
    }
    while(!q.empty()){
        ll top=q.top();
        q.pop();
        if(!q.empty() and q.top()==top)
        {
            q.pop();
            q.push(top-1);
        }
        else c++;
    }
    cout<<c<<'\n';
    return 0;
}


#pragma GCC optimize("Ofast", "inline", "unroll-loops", "no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int n,inp;
ll c,top;
priority_queue<ll> q;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&inp); q.push(-inp);
    }
    while(!q.empty()){
        top=q.top();
        q.pop();
        if(!q.empty() and q.top()==top)
        {
            q.pop();
            q.push(top-1);
        }
        else c++;
    }
    printf("%lld\n",c);
    return 0;
}


#pragma GCC optimize("Ofast", "inline", "unroll-loops", "no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int n,inp;
ll c;
priority_queue<ll> q;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&inp); q.push(-inp);
    }
    while(!q.empty()){
        ll top=q.top();
        q.pop();
        if(!q.empty() and q.top()==top)
        {
            q.pop();
            q.push(top-1);
        }
        else c++;
    }
    cout<<c<<'\n';
    return 0;
}


#pragma GCC optimize("Ofast", "inline", "unroll-loops", "no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int n,inp;
ll c,top;
priority_queue<ll> q;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&inp); q.push(-inp);
    }
    while(!q.empty()){
    top=q.top();
        q.pop();
        if(!q.empty() and q.top()==top)
        {
            q.pop();
            q.push(top-1);
        }
        else c++;
    }
    cout<<c<<'\n';
    return 0;
}


/*
Sharif Hasan - CSE, PUST
Nov 17, 2019 06: 40 PM
*/
#include<bits/stdc++.h>
#define br cout<<"\n"
#define FOR(i,n) for(int i=0;i<n;i++)
#define FROM(a,i,n) for(int i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
/*Main function*/
int main()
{
int n,cnt=0;
cin>>n;
int arr[n];
FOR(i,n) cin>>arr[i];
sort(arr,arr+n);
map <int,int> log;
FOR(i,n){
    log[arr[i]]++;
    if(log[arr[i]]>=2) {
        int k = arr[i];
        while (1) {
            log[k] -= 2;
            if (log[k + 1]) {
                k++, cnt--;
                log[k]++;
            } else {
                ++log[k + 1];
                break;
            }
        }
    }else{
        cnt++;
    }
}
cout<<cnt;br;
return 0;
}


/*
Sharif Hasan - CSE, PUST
Nov 17, 2019 06: 40 PM
*/
#include<bits/stdc++.h>
#define br cout<<"\n"
#define FOR(i,n) for(int i=0;i<n;i++)
#define FROM(a,i,n) for(int i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

/*Main function*/
int main()
{
int n,cnt=0;
cin>>n;
int arr[n];
FOR(i,n) cin>>arr[i];
vector <int> log;
FOR(i,1000001) log.push_back(0);
FOR(i,n){
log[arr[i]]++;
if(log[arr[i]]>=2){
    int d = arr[i];
    while(1){
        log[d]-=2;
        if(log[d+1]){
            d++;cnt--;
            log[d]++;
        }else{
            log[d+1]++;
            break;
        }
    }
}else{
    cnt++;
}
}
cout<<cnt;br;
return 0;
}


    /*
    Sharif Hasan - CSE, PUST
    Nov 17, 2019 06: 40 PM
    */
    #include<bits/stdc++.h>
    #define br cout<<"\n"
    #define FOR(i,n) for(int i=0;i<n;i++)
    #define FROM(a,i,n) for(int i=a;i<n;i++)
    #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    using namespace std;

    /*Main function*/
    int main()
    {
    int n,cnt=0;
    cin>>n;
    int arr[n];
    FOR(i,n) cin>>arr[i];
    sort(arr,arr+n);
    vector <int> log;
    FOR(i,1000001) log.push_back(0);
    FOR(i,n){
    log[arr[i]]++;
    if(log[arr[i]]>=2){
        int d = arr[i];
        while(1){
            log[d]-=2;
            if(log[d+1]){
                d++;cnt--;
                log[d]++;
            }else{
                log[d+1]++;
                break;
            }
        }
    }else{
        cnt++;
    }
    }
    cout<<cnt;br;
    return 0;
    }


/*
Sharif Hasan - CSE, PUST
Nov 17, 2019 06: 40 PM
*/
#include<bits/stdc++.h>
#define br cout<<"\n"
#define FOR(i,n) for(int i=0;i<n;i++)
#define FROM(a,i,n) for(int i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
/*Main function*/
int main()
{
int n,cnt=0;
cin>>n;
ll arr[n];
FOR(i,n) cin>>arr[i];
sort(arr,arr+n);
map <ll,ll> log;
FOR(i,n){
    log[arr[i]]++;
    if(log[arr[i]]>=2) {
        int k = arr[i];
        while (1) {
            log[k] -= 2;
            if (log[k + 1]) {
                ++k, ++cnt;
                ++log[k];
            } else {
                ++log[k + 1];
                break;
            }
        }
    }else{
        cnt++;
    }
}
cout<<cnt;br;
return 0;
}


    /*
    Sharif Hasan - CSE, PUST
    Nov 17, 2019 06: 40 PM
    */
    #include<bits/stdc++.h>
    #define br cout<<"\n"
    #define FOR(i,n) for(int i=0;i<n;i++)
    #define FROM(a,i,n) for(int i=a;i<n;i++)
    #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    using namespace std;

    /*Main function*/
    int main()
    {
    IOS;
    int n,cnt=0;
    cin>>n;
    int arr[n];
    FOR(i,n) cin>>arr[i];
    vector <int> log;
    FOR(i,1000001) log.push_back(0);
    FOR(i,n){
    log[arr[i]]++;
    if(log[arr[i]]>=2){
        int d = arr[i];
        while(1){
            log[d]-=2;
            if(log[d+1]){
                d++;cnt--;
                log[d]++;
            }else{
                log[d+1]++;
                break;
            }
        }
    }else{
        cnt++;
    }
    }
    cout<<cnt;br;
    return 0;
    }


/*
Sharif Hasan - CSE, PUST
Nov 17, 2019 06: 40 PM
*/
#include<bits/stdc++.h>
#define br cout<<"\n"
#define FOR(i,n) for(int i=0;i<n;i++)
#define FROM(a,i,n) for(int i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
/*Main function*/
int main()
{
int n,cnt=0;
cin>>n;
ll arr[n];
FOR(i,n) cin>>arr[i];
sort(arr,arr+n);
map <ll,ll> log;
FOR(i,n){
    log[arr[i]]++;
    if(log[arr[i]]>=2) {
        int k = arr[i];
        while (1) {
            log[k] -= 2;
            if (log[k + 1]) {
                k++, cnt--;
                ++log[k];
            } else {
                log[k + 1]++;
                break;
            }
        }
    }else{
        cnt++;
    }
}
cout<<cnt;br;
return 0;
}


    /*
    Sharif Hasan - CSE, PUST
    Nov 17, 2019 06: 40 PM
    */
    #include<bits/stdc++.h>
    #define br cout<<"\n"
    #define FOR(i,n) for(int i=0;i<n;i++)
    #define FROM(a,i,n) for(int i=a;i<n;i++)
    #define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    using namespace std;

    /*Main function*/
    int main()
    {
    int n,cnt=0;
    cin>>n;
    vector <int> arr;
    FOR(i,n){
        int k;
        cin>>k;
        arr.push_back(k);
    }
    sort(arr.begin(),arr.end());
    vector <int> log;
    FOR(i,1000001) log.push_back(0);
    FOR(i,n){
    log[arr[i]]++;
    if(log[arr[i]]>=2){
        int d = arr[i];
        while(1){
            log[d]-=2;
            if(log[d+1]){
                d++;cnt--;
                log[d]++;
            }else{
                log[d+1]++;
                break;
            }
        }
    }else{
        cnt++;
    }
    }
    cout<<cnt;br;
    return 0;
    }


#include<bits/stdc++.h>
using namespace std;
#define re register
#define gcd __gcd
#define Fi first
#define Se second
//#define mp make_pair
#define lowbit(x) ((x)&-(x))
typedef long long LL;
typedef pair<int,int> pii;
const int N = 1e6+7;
const int M = 1e6+7;
const int lim = 1e6;
const int P = 998244353;
const int inf = 0x3f3f3f3f;
int n,k,mx,x,y,ans,mi=inf;
int a[N],b[N];
map<LL,int> mp;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[a[i]]++;
	}
	sort(a+1,a+1+n);
	for(int i=0;i<=lim;i++)
	{
		b[i+1] += b[i]/2;
		if( b[i] % 2 == 1 )
			ans++;
	}
	printf("%d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define re register
#define gcd __gcd
#define Fi first
#define Se second
//#define mp make_pair
#define lowbit(x) ((x)&-(x))
typedef long long LL;
typedef pair<int,int> pii;
const int N = 2e6+7;
const int M = 1e6+7;
const int lim = 2e6;
const int P = 998244353;
const int inf = 0x3f3f3f3f;
int n,k,mx,x,y,ans,mi=inf;
int a[N],b[N];
map<LL,int> mp;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[a[i]]++;
	}
	sort(a+1,a+1+n);
	for(int i=0;i<=lim;i++)
	{
		b[i+1] += b[i]/2;
		if( b[i] % 2 == 1 )
			ans++;
	}
	printf("%d\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#include<string.h>
//
#define ll long long
#define si set<int>
#define sll set<ll>
#define sc set<char>
#define lcm(a,b) a*b/__gcd(a,b)
#define siitr set<int>::iterator
#define scit set<char>::iterator
#define mp make_pair
#define mapint map<int, int >
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vb vector<bool>
#define vd vector<double>
#define vviitr vector<vector<int> >::iterator
#define vvi vector<vector<int> >
#define vvc vector< vector<char> >
#define vvb vector<vector<bool> >
#define viitr vector<int>::iterator
#define vcitr vector<char>::iterator
#define f(i,j,n,k) for(int i=j;i<=n;i+=k)
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define pb push_back

#define endl '\n'
#define hell 1000000007

using namespace std;
//functions
ll gcdfun(ll x, ll y){ if(y==0) return x; else return gcdfun(y,x%y); }
void swap(char * x, char * y){ char c ; c = *x; *x = *y; *y = c;}
ll minfun(ll x, ll y){ if(x>y) return y; else return x;}
//ll power(ll x){return x*x;}

int main(){

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// time 15 53
 	int n; cin>>n; vi cnt(10000002,0);
 	vi v(n); f(i,0,n-1,1) cin>>v[i],cnt[v[i]]++;
 	f(i,0,10000000,1){
 		if(cnt[i]>=2){
 			cnt[i+1]+=cnt[i]/2;
 			cnt[i]=cnt[i]%2;
 		}
 	}
 	int ans = 0;
 	f(i,0,10000000,1){
 		if(cnt[i]>0) ans++;
 	}
 	cout<<ans;
 }


#include<bits/stdc++.h>
#include<string.h>
//
#define ll long long
#define si set<int>
#define sll set<ll>
#define sc set<char>
#define lcm(a,b) a*b/__gcd(a,b)
#define siitr set<int>::iterator
#define scit set<char>::iterator
#define mp make_pair
#define mapint map<int, int >
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vb vector<bool>
#define vd vector<double>
#define vviitr vector<vector<int> >::iterator
#define vvi vector<vector<int> >
#define vvc vector< vector<char> >
#define vvb vector<vector<bool> >
#define viitr vector<int>::iterator
#define vcitr vector<char>::iterator
#define f(i,j,n,k) for(int i=j;i<=n;i+=k)
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define pb push_back

#define endl '\n'
#define hell 1000000007

using namespace std;
//functions
ll gcdfun(ll x, ll y){ if(y==0) return x; else return gcdfun(y,x%y); }
void swap(char * x, char * y){ char c ; c = *x; *x = *y; *y = c;}
ll minfun(ll x, ll y){ if(x>y) return y; else return x;}
//ll power(ll x){return x*x;}

int main(){

#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// time 15 53
 	int n; cin>>n; vi cnt(1000005,0);
 	vi v(n); f(i,0,n-1,1) cin>>v[i],cnt[v[i]]++;
 	f(i,0,1000000,1){
 		if(cnt[i]>=2){
 			cnt[i+1]+=cnt[i]/2;
 			cnt[i]=cnt[i]%2;
 		}
 	}
 	int ans = 0;
 	f(i,0,1000004,1){
 		if(cnt[i]>0) ans++;
 	}
 	cout<<ans;
 }


#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
const ll mod=1000000007;
const int maxn=1000000+100;
void open1(int x){
	char s[20]="";
	int a[20],sum=0;
	while(x){
		a[sum++]=x%10;
		x/=10;
	}
	for(int i=sum-1;i>=0;i--) s[sum-1-i]+=a[i]+'0';
	s[sum]='.',s[sum+1]='i',s[sum+2]='n',s[sum+3]='\0';
	freopen(s,"r",stdin);
}
void open2(int x){
	char s[20]="";
	int a[20],sum=0;
	while(x){
		a[sum++]=x%10;
		x/=10;
	}
	for(int i=sum-1;i>=0;i--) s[sum-1-i]+=a[i]+'0';
	s[sum]='.',s[sum+1]='o',s[sum+2]='u',s[sum+3]='t',s[sum+4]='\0';
	freopen(s,"w",stdout);
}
int num[maxn];
int solution(int n,vector<int> m){
	memset(num,0,sizeof(num));
	for(int i=0;i<n;i++){
		num[m[i]]++;
	}
	int ans=0;
	for(int i=1;i<maxn;i++){
		num[i]+=num[i-1]/2;
		num[i-1]%=2;
		ans+=num[i-1];
	}
	return ans;
}
int main()
{
//	for(int it=1;it<=30;it++){
//		open1(it);
//		open2(it);
		int n;
		char x;
		scanf("%d",&n);
		vector<int>m(n,0);
		for(int i=0;i<n;i++){
			scanf("%d",&m[i]);
		}
		printf("%d\n",solution(n,m));
//	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
const ll mod=1000000007;
const int maxn=1000000+10;
void open1(int x){
	char s[20]="";
	int a[20],sum=0;
	while(x){
		a[sum++]=x%10;
		x/=10;
	}
	for(int i=sum-1;i>=0;i--) s[sum-1-i]+=a[i]+'0';
	s[sum]='.',s[sum+1]='i',s[sum+2]='n',s[sum+3]='\0';
	freopen(s,"r",stdin);
}
void open2(int x){
	char s[20]="";
	int a[20],sum=0;
	while(x){
		a[sum++]=x%10;
		x/=10;
	}
	for(int i=sum-1;i>=0;i--) s[sum-1-i]+=a[i]+'0';
	s[sum]='.',s[sum+1]='o',s[sum+2]='u',s[sum+3]='t',s[sum+4]='\0';
	freopen(s,"w",stdout);
}
int num[maxn];
int solution(int n,vector<int> m){
	memset(num,0,sizeof(num));
	for(int i=0;i<n;i++){
		num[m[i]]++;
	}
	int ans=0;
	for(int i=1;i<maxn;i++){
		num[i]+=num[i-1]/2;
		num[i-1]%=2;
		ans+=num[i-1];
	}
	return ans;
}
int main()
{
//	for(int it=1;it<=30;it++){
//		open1(it);
//		open2(it);
		int n;
		char x;
		scanf("%d",&n);
		vector<int>m(n,0);
		for(int i=0;i<n;i++){
			scanf("%d",&m[i]);
		}
		printf("%d\n",solution(n,m));
//	}
	return 0;
}


#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    int a[n];
    for(int i = 0; i<n; i++){
        cin>>a[i];
    }
    ll sum = 0;
    int ans = 1;
    for(int i = 0; i<n-1; i++){
        sum+=a[i];
        if(sum == a[i+1]){
            continue;
        }else{
            sum = 0;
            ans++;
        }
    }
    cout<<ans;
}


#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define MOD 1000000007
const int N = 1e6 + 100;
int cnt[N]={0};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    for(int i = 0; i<n; i++){
        int x;
        cin>>x;
        cnt[x]++;
    }
    int ans = 0;

    for(int i = 0; i<20; i++){
        cnt[i+1]+=cnt[i]/2;
        cnt[i]%=2;
        ans+=cnt[i];
    }

    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#include<string>
#include<cmath>

using namespace std;

#define ll long long int
#define loop(i, n) for (int i = 0; i < n; i++)
#define loops(i, s, n) for (int i = s; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define MOD 1000000007
const int N = 2e6 + 100;
int cnt[N]={0};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    for(int i = 0; i<n; i++){
        int x;
        cin>>x;
        cnt[x]++;
    }
    int ans = 0;

    for(int i = 0; i<N; i++){
        if(cnt[i]){
        cnt[i+1]+=cnt[i]/2;
        cnt[i]%=2;
        if(cnt[i]){
            ans++;
        }
        }
    }

    cout<<ans;
    return 0;
}


                #include<bits/stdc++.h>
                #define ll            long long
                #define pb            push_back
                #define ppb           pop_back
                #define si            set <ll>
                #define endl          '\n'
                #define fr            first
                #define sc            second
                #define mii           map<ll ,ll >
                #define msi           map<string,ll >
                #define mis           map<ll , string>
                #define rep(i,a,b)    for(ll  i=a;i<b;i++)
                #define all(v)        v.begin(),v.end()
                #define sort(v)       sort(all(v))
                #define pii           pair<ll ,ll >
                #define vi            vector<ll >
                #define vii           vector<pair<ll , ll >>
                #define vs            vector<string>
                #define sz(x)         (ll )x.size()
                #define M             1000000007
                #define bs            binary_search
                #define mp            make_pair
                #define sp(n)         setprecision(n)
                #define spl           " "
                #define arr(a,n)      rep(i,0,n) cin>>a[i]
                #define mod           998244353
                #define show(a)       for(auto it:a) cout<<it<<" "; cout<<endl;
                #define what_is(x)    cout << #x << " is " << x << endl;
                using namespace std;
                ll modularExponentiation(ll x,ll n,ll mm)
                {
                    ll result=1;
                    while(n>0)
                    {
                        if(n% 2 ==1)
                            result=(result * x)%mm;
                        x=(x*x)%mm;
                        n=n/2;
                    }
                    return result;
                }
                ll fib(ll n)
                {
                  long double phi = (1 + sqrt(5)) / 2;
                  return round(pow(phi, n) / sqrt(5));
                }
                vector<bool> prime(100000,true);
                void SieveOfEratosthenes()
                {
                    prime[0]=false;
                    prime[1]=false;
                    for (ll p=2; p*p<=prime.size(); p++)
                    {
                        if(prime[p] == true)
                        {
                          for (ll i=p*p; i<=prime.size(); i += p)
                            prime[i] = false;
                        }
                    }
                }
                vector<ll> g[1001];
                vector<bool> vis(1001,false);
                void dfs(ll p)
                {

                    vis[p]=true;
                    for(auto it:g[p])
                        if(!vis[it])
                            dfs(it);
                        else {cout<<it<<" ";break;}

                }
                ll min(ll a,ll b)
                {
                    return a<b?a:b;
                }
                ll check(ll n)
                {
                    ll k=sqrt(n);
                    return k*k==n;
                }
                set<ll> primeFactors(ll n)
                {
                    set<ll> st;
                    while (n%2 == 0)
                    {
                        st.insert(2);
                        n = n/2;
                    }
                    for (ll i = 3; i <= sqrt(n); i = i+2)
                    {
                        while (n%i == 0)
                        {
                            st.insert(i);
                            n = n/i;
                        }
                    }
                    if (n > 2)
                        st.insert(n);
                    return st;
                }
                void solve()
                {
                   ll n;
                   cin>>n;
                   map<ll,ll> mp;
                   rep(i,0,n)
                   {
                    ll t;
                    cin>>t;
                    mp[t]++;
                   }
                   ll res=0;
                   rep(i,0,1000009)
                   {
                    if(mp[i]%2)
                        res++,mp[i]--;
                    mp[i+1]+=mp[i]/2;
                   }
                   cout<<res;
                }

                signed main()
                {
                    ios_base::sync_with_stdio(false);
                    cin.tie(0);
                    cout.tie(0);
                    #ifndef ONLINE_JUDGE
                    freopen("input.txt","r",stdin);
                    freopen("output.txt","w",stdout);
                    #endif
                    ll t=1;
                    //cin>>t;
                    while(t--) solve();
                }


                #include<bits/stdc++.h>
                #define ll            long long
                #define pb            push_back
                #define ppb           pop_back
                #define si            set <ll>
                #define endl          '\n'
                #define fr            first
                #define sc            second
                #define mii           map<ll ,ll >
                #define msi           map<string,ll >
                #define mis           map<ll , string>
                #define rep(i,a,b)    for(ll  i=a;i<b;i++)
                #define all(v)        v.begin(),v.end()
                #define sort(v)       sort(all(v))
                #define pii           pair<ll ,ll >
                #define vi            vector<ll >
                #define vii           vector<pair<ll , ll >>
                #define vs            vector<string>
                #define sz(x)         (ll )x.size()
                #define M             1000000007
                #define bs            binary_search
                #define mp            make_pair
                #define sp(n)         setprecision(n)
                #define spl           " "
                #define arr(a,n)      rep(i,0,n) cin>>a[i]
                #define mod           998244353
                #define show(a)       for(auto it:a) cout<<it<<" "; cout<<endl;
                #define what_is(x)    cout << #x << " is " << x << endl;
                using namespace std;
                ll modularExponentiation(ll x,ll n,ll mm)
                {
                    ll result=1;
                    while(n>0)
                    {
                        if(n% 2 ==1)
                            result=(result * x)%mm;
                        x=(x*x)%mm;
                        n=n/2;
                    }
                    return result;
                }
                ll fib(ll n)
                {
                  long double phi = (1 + sqrt(5)) / 2;
                  return round(pow(phi, n) / sqrt(5));
                }
                vector<bool> prime(100000,true);
                void SieveOfEratosthenes()
                {
                    prime[0]=false;
                    prime[1]=false;
                    for (ll p=2; p*p<=prime.size(); p++)
                    {
                        if(prime[p] == true)
                        {
                          for (ll i=p*p; i<=prime.size(); i += p)
                            prime[i] = false;
                        }
                    }
                }
                vector<ll> g[1001];
                vector<bool> vis(1001,false);
                void dfs(ll p)
                {

                    vis[p]=true;
                    for(auto it:g[p])
                        if(!vis[it])
                            dfs(it);
                        else {cout<<it<<" ";break;}

                }
                ll min(ll a,ll b)
                {
                    return a<b?a:b;
                }
                ll check(ll n)
                {
                    ll k=sqrt(n);
                    return k*k==n;
                }
                set<ll> primeFactors(ll n)
                {
                    set<ll> st;
                    while (n%2 == 0)
                    {
                        st.insert(2);
                        n = n/2;
                    }
                    for (ll i = 3; i <= sqrt(n); i = i+2)
                    {
                        while (n%i == 0)
                        {
                            st.insert(i);
                            n = n/i;
                        }
                    }
                    if (n > 2)
                        st.insert(n);
                    return st;
                }
                void solve()
                {
                   ll n;
                   cin>>n;
                   map<ll,ll> mp;
                   rep(i,0,n)
                   {
                    ll t;
                    cin>>t;
                    mp[t]++;
                   }
                   ll res=0;
                   rep(i,0,2000001)
                   {
                    mp[i+1]+=mp[i]/2;
                    if(mp[i]&1) res++;
                   }
                   cout<<res;
                }

                signed main()
                {
                    ios_base::sync_with_stdio(false);
                    cin.tie(0);
                    cout.tie(0);
                    #ifndef ONLINE_JUDGE
                    freopen("input.txt","r",stdin);
                    freopen("output.txt","w",stdout);
                    #endif
                    ll t=1;
                    //cin>>t;
                    while(t--) solve();
                }