You are given a sequence of N integer numbers A. Calculate the sum of Ai AND Aj for all the pairs (i, j) where i < j. 
 The AND operation is the Bitwise AND operation, defined as in here. 

Input
The first line of input consists of the integer N. 
The second line contains N integer numbers - the sequence A.

Output
Output the answer to the problem on the first line of the output.

Example
Input:
5
1 2 3 4 5

Output:
9


Scoring

Subtask 1 (13 points): N <= 1000, Ai <= 1. 
Subtask 2 (39 points): N <= 1000, Ai <= 10^9. 
Subtask 3 (21 points): N <= 10^5, Ai <= 1. 
Subtask 4 (27 points): N <= 10^5, Ai <= 10^6.
import fileinput
import math


foundN = False
for line in fileinput.input():
    if not foundN:
        N = int(line)
        foundN = True
        continue
    
    number_list = map(int, line.split())
    bit_count = [0]*31
    
    for number in number_list:
        for i in range(31):
            if number & (1 << i):
                bit_count[i] += 1
    
    
    total = 0
    for i in range(31):
        hits = bit_count[i]
        
        local_sum = 0
        for k in range(hits):
            local_sum += k
        
        mult_fact = int(math.pow(2, i))
        total += local_sum * mult_fact
        
    
    print total