n = int(input())
a = list(map(int, input().split()))
c = [0 for _ in range(len(bin(max(a))) - 2)]
len_c = len(c)
ans = 0
mod = 10**9 + 7
cnt = 0
for i in range(n):
  binlist = list(map(int, list('0' * (len_c - len(bin(a[i])) + 2) + bin(a[i])[2:])))
  for j in range(len_c):
    if binlist[j] == 0:
      ans = (ans + c[j] * (2**(len_c-j-1))) % mod
    else:
      ans = (ans + (cnt - c[j]) * (2**(len_c-j-1))) % mod
      c[j] += 1
  cnt += 1
print(ans)