import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = rl()
MOD = 10 ** 9 + 7
#1番目以降(N個の数)のbitの格桁の合計
l = [0] * 60
for i in range(N):
    s = list(str(bin(A[i]))[2:].rjust(60, '0'))
    #print(s)
    for j in range(60):
        if s[j] == '1':
            l[j] += 1
l2 = [0] * 60
#print(l)
for i in range(N-1):
    s = list(str(bin(A[i]))[2:].rjust(60, '0'))
    x = N - 1 - i
    for j in range(60):
        if s[j] == '1':
            l[j] -= 1
            l2[j] += x - l[j]
        else:
            l2[j] += l[j]
answer = 0
#print(l2)
for i in range(60):
    answer += 2 ** (59-i) * l2[i]
    answer %= MOD
#print(l)
print(answer)

