n = int(input())
a = list(map(int, input().split()))
import numpy as np
c = np.array([0 for _ in range(len(bin(max(a))) - 2)])
len_c = len(c)
ans = 0
mod = 10**9 + 7
for i in range(n):
  b = bin(a[i])[2:]
  binlist = np.array(list('0' * (len_c - len(b)) + b)).astype('int64')
  c += binlist 
for i in range(len_c):
  ans += 2 ** (len_c-i-1) * c[i] * (n - c[i])
  ans %= mod
print(ans)