import numpy as np

n = int(input())
lst = np.array([int(i) for i in input().split()])
mod = 10 ** 9 + 7
c = []

while lst.any():
    c1 = sum(lst & 1)
    c.append(c1 * (n - c1))
    lst >>= 1
print(sum([v * 2 ** i for i, v in enumerate(c)]))