N = int(input())

d = []
for j in range(60):
  d.append(0)

A = [int(_) for _ in input().split()]

for i in range(N):
  for j in range(60):
    if (A[i] & (1 << j)) != 0:
      d[j] += 1

sum = 0
for i in range(N):
  for j in range(60):
    if (A[i] & (1 << j)) != 0:
      sum += (1 << j) * (N - i - d[j])
      d[j] -= 1
    else:
      sum += (1 << j) * d[j]

print(sum % 1000000007)

