N = int(input())
A = [int(i) for i in input().split()]

M = max(A)
m = M
a = 1
while m // 2 != 0:
  m = m//2
  a += 1
#aはMの桁数

b = 0
for i in range(a):
  c = 0
  for j in range(N):
    c += (A[j] & 2**i)//(2**i)  #A[j]の2**iの位の値をcに加えている
  b = (b + c*(N-c)*pow(2,i,10**9+7)) % (10**9+7)
  
print(b)