n = int(input())
l = list(map(int, input().split()))

l.sort(reverse=True)
kmax = len(format(l[0], 'b'))

l0 = [0]*kmax
l1 = [0]*kmax

for i in range(n):
  a = format(l[i], 'b')
  a = ''.join(list(reversed(a)))
  for j in range(kmax):
    if j > len(a)-1:
      l0[j] += 1
    elif a[j] == '0':
      l0[j] += 1
    else:
      l1[j] += 1

ans = 0
for k in range(kmax):
  ans += l0[k]*l1[k]*(2**k)
  ans %= 10**9+7
print(ans)