n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
ml = len(bin(max(a)))-2
ans = 0
for i in range(ml):
  x = sum([1 for j in range(n) if ((a[j]>>i) & 1)])
  ans += x*(n-x)*(2**i)
  ans %= mod
print(ans)