问题 CG: 举重

内存限制:256 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:12 通过:5

题目描述

达夫是一个举重运动员。作为一项艰苦的练习,教练给了他一项任务。教练给了她一系列重量。其中第i个的重量是2wi磅。在每一步中,达夫都可以举起一些剩余的重物并扔掉。她这样做,直到没有更多的重量。教练要求他尽量减少步数。 

达夫也是一位极具竞争力的编程爱好者。这就是为什么在每一步中,她只能举起和扔掉一系列的权重2a1,…,2ak,当且仅当存在一个非负整数x,使得2a1+2a2+…+2ak

=2x,即这些数字的和是2的幂。

        达夫是一个有竞争力的编程爱好者,但不是程序员。这就是她请求你帮助的原因。帮助她尽量减少步数。



n个数w1,w2......wn1,wn,若有kw值满足存在一个数x使得2x为这k2w的和,则这一组合是合法的,我们希望找到最小的组数m,使这nw组成m个合法组合。

给出nwi,输出最小的m

         Recently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2wi pounds. In each step, Duff can lift some of the remaining weights and throw them away. She does this until there's no more weight left. Malek asked her to minimize the number of steps. 



Duff is a competitive programming fan. That's why in each step, she can only lift and throw away a sequence of weights 2�1,...,2��2a1,...,2ak if and only if there exists a non-negative integer x such that 2�1+2�2+...+2��=2�2a1+2a2+...+2ak=2x , i. e. the sum of those numbers is a power of two.



Duff is a competitive programming fan, but not a programmer. That's why she asked for your help. Help her minimize the number of steps.

Input

The first line of input contains integer n (1 ≤ n ≤ 106), the number of weights.

The second line contains n integers w1, ..., wn separated by spaces (0 ≤ wi ≤ 106 for each 1 ≤ in), the powers of two forming the weights values.

Output

Print the minimum number of steps in a single line.

Examples



Note

In the first sample case: One optimal way would be to throw away the first three in the first step and the rest in the second step. Also, it's not possible to do it in one step because their sum is not a power of two.

In the second sample case: The only optimal way is to throw away one weight in each step. It's not possible to do it in less than 4 steps because there's no subset of weights with more than one weight and sum equal to a power of two.





输入格式

第一行输入包含整数n(1≤n≤106)、权重的数量。

        第二行包含n个整数w1,…,wn,用空格(0≤维≤106个,每个1个≤我≤n) ,二的幂构成权重值。

输出格式

在单行中打印最小步数。

示例

input


1 1 2 3 3
output

2


input

4

0 1 2 3
output
4

在第一个示例中:一个最佳的方法是在第一步中丢弃前三个,在第二步中丢弃其余的。而且,不可能一步到位,因为它们的和不是二的幂。

在第二个例子中:唯一的最佳方法是在每一步中丢掉一个重量。不可能在4个步骤内完成,因为没有超过一个权重的权重子集,并且总和等于2的幂。

输入样例 复制

5
1 1 2 3 3

输出样例 复制

2