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


class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());

        PriorityQueue<Long> pq = new PriorityQueue<>();

        StringTokenizer st = new StringTokenizer(br.readLine());
        for (int i=0; i<N; i++) {
            pq.add(Long.parseLong(st.nextToken()));
        }

        int ans = 0;
        
        while(!pq.isEmpty()) {
            long current = pq.poll();

            if (!pq.isEmpty() && pq.peek() == current) {
                pq.poll();
                pq.add(current*2);
            } else {
                ans ++;
            }
            
        }
        System.out.println(ans);
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: