# -*- coding: utf-8 -*-

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    SUM = sum(A)
    B = {}
    for a in A:
        for i, b in enumerate(bin(a)[2:][::-1]):
            B[i] = B.get(i,0) + int(b)
    res = (N-1)*SUM + sum(2**i*(B[i]*(N+1-2*B[i])) for i in B)
    return str(res//2)

if __name__ == '__main__':
    print(solve())
