n = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7

dig = 60
Abn = [[0]*dig for _ in range(n)]

for i in range(n):
  for j in range(dig):
    if A[i]>>j&1:
      Abn[i][j] = 1
      

Cbn0 = [[0]*dig for i in range(n)]
Cbn1 = [[0]*dig for i in range(n)]

for j in range(dig):
  if Abn[n-1][j]==1:
    Cbn1[n-1][j] = 1
  else:
    Cbn0[n-1][j] = 1
    
for i in range(n-2, 0, -1):
  for j in range(dig):
    if Abn[i][j]==1:
      Cbn0[i][j] = Cbn0[i+1][j]
      Cbn1[i][j] = Cbn1[i+1][j] + 1
    else:
      Cbn0[i][j] = Cbn0[i+1][j] + 1
      Cbn1[i][j] = Cbn1[i+1][j]

ans = 0
two = [pow(2, i, MOD) for i in range(dig)]

for i in range(n-1):
  for j in range(dig):
    if Abn[i][j] == 1:
      ans += Cbn0[i+1][j] * two[j] % MOD
    else:
      ans += Cbn1[i+1][j] * two[j] % MOD
    ans %= MOD
    
print(ans)
