import math
import  numpy as np

N = int(input())
a = list(map(int, input().split()))

na = np.array(a)

ans = 0
a_max = max(a)

if a_max==0:alog=1
else:alog = int(math.log2(a_max))+1
  
for i in range(alog):
    p = pow(2, i)
    cnt = sum([np.bitwise_and(na, p)==p])
    s = np.sum(cnt)
    ans += s * (N - s)*(2**i)%(10**9+7)

print(ans%(10**9+7))
