N = int(input())
A = list(map(lambda x: format(int(x), '060b'), input().split(' ')))
mod = 10 ** 9
zero = [N]*60
one = [N]*60
ans = 0
cnt = 0
for i in A:
    cnt = max(cnt, len(i))
    for n, j in enumerate(i[::-1]):
        if int(j):
            zero[n] -= 1
        else:
            one[n] -= 1
for n, x in enumerate(zip(zero, one)):
    ans += pow(2,n,mod) * x[0]* x[1] % mod
    ans %= mod
print(ans)
