import sys
import numpy as np

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 = np.array([0] * 60)
for i in range(N):
    s = np.array(list(map(int, list(str(bin(A[i]))[2:].rjust(60, '0')))))
    #print(s)
    l = l + s
l2 = np.array([0] * 60)
#print(l)
for i in range(N-1):
    s = np.array(list(map(int, list(str(bin(A[i]))[2:].rjust(60, '0')))))
    x = N - 1 - i
    l -= s
    l2 += s * (x-l)
    l2 += (1-s) * l
    
answer = 0
#print(l2)
l2 = l2.tolist()
for i in range(60):
    answer += 2 ** (59-i) * l2[i]
    answer %= MOD
#print(l)
print(answer)

