MOD = 10**9+7
N = int(input())
A = list(map(int, input().split()))
s = 0
n = len(bin(max(A))[2:])
for i in range(n):
  b = 1<<i
  N_t = sum([1 for Ai in A if (b&Ai)>0])
  N_f = N-N_t
  s += (1<<i) * N_t * N_f
print(s%MOD)
