n = int(input())
a = sorted([int(i) for i in input().split()], reverse=True)
mod = 10**9 + 7
ans = 0
for j in range(len(bin(a[0])) - 2):
  k = [0, 0]
  for i in a:
    k[i >> j & 1] += 1
  ans = (ans + (k[0] * k[1]) * 2**j) % mod
print(ans)