import numpy as np
n = int(input())
a = list(map(int, input().split()))
p = 10**9 + 7
num_a = np.array([0]*60)
str_a = []
for i in a:
  a_str = list(format(i, 'b').zfill(60))
  a_str = list(map(int, a_str))
  num_a = num_a + np.array(a_str)
num_a =reversed(num_a)
ans = 0
for i, j in enumerate(num_a):
  ans =  (ans + j*(n-j)*2**i)%p

print(ans)