import collections as c
ip = lambda : map(int, input().split())
mod = 10**9+7
# ##############
N = int(input())
l = list(ip())
l.reverse()
v = [0]*60
av = [0]*60
for i in range(len(l)):
    for j in range(60):
        if i>0:
            if l[i]>>j & 1:
                av[j]+=i-v[j]
            else:
                av[j] += v[j]
        if l[i]>>j & 1:
            v[j]+=1
ans = 0
p2 = [1]*60
for i in range(1,60):
    p2[i] = p2[i-1]*2%mod
for i in range(60):
    ans = (ans + av[i]*p2[i]%mod)%mod
print(ans)