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
for i in range(n):
  b = bin(a[i])[2:]
  binlist = list('0' * (len_c - len(b)) + b)
  for j in range(len_c):
    power = 2**(len_c-j-1)
    if binlist[j] == '0':
      ans = (ans + c[j] * power) % mod
    else:
      ans = (ans + (i - c[j]) * power) % mod
      c[j] += 1
print(ans)