import sys
from itertools import combinations as combi
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
cs = [[0] * 61 for _ in range(N + 1)]
mod = 10 ** 9 + 7
for i in range(N):
  for j in range(61):
    t = 1 << j
    #print(a[i], t, a[i] & t)
    cs[i + 1][j] = cs[i][j] + (a[i] & t)
res = 0
#print(cs[-1])
#print(cs[2])
for i in range(N):
  t = 0
  for j in range(61):
    if a[i] & (1 << j) != 0:
      #if i == 1: print((1 << j) * (N - i - 1), (cs[-1][j] - cs[i + 1][j]))
      t += (1 << j) * (N - i - 1) - (cs[-1][j] - cs[i + 1][j])
    else:
      #if i == 1: print(a[i] & (1 << j), (cs[-1][j] - cs[i + 1][j]))
      t += (cs[-1][j] - cs[i + 1][j])
    #if i == 1: print(t)
    t %= mod
  res += t
  res %= mod
print(res % mod)