import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
a.sort()

inf = pow(10, 9)+7
key = max(a)

k = 1
while key > 1:
  k += 1
  key //= 2
sub = [0]*k

ans = 0
for i in range(n):
  value = a[i]
  value_bin = [0]*k
  q = 0
  p = 0
  while value > 0:
    if value%2 == 1:
      value_bin[p] += 1
    p += 1
    value //= 2
  if p > q:
    q = p
  if i == 0:
    for j in range(q):
      if value_bin[p] == 1:
        sub[p] = 1
  r = 1
  for j in range(q):
    if value_bin[j] == 1:
      ans += (r*(i-sub[j]))%inf
      sub[j] += 1
    else:
      ans += (r*sub[j])%inf
    r *= 2
    ans %= inf

print(ans)