import numpy as np
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int,input().split()))
ma = max(a)
maketa = len(bin(ma))-2
mat = np.zeros((N,maketa))
for i,elem in enumerate(a):
    mat[i] = np.array(list(bin(elem)[2:].zfill(maketa)))
res = 0
mat = mat.T
dic = {}
for i in range(maketa):
    dic[i] = int(np.sum(mat[maketa-i-1]))
for i in range(maketa):
    num = dic[i]
    res += num*(N-num)*(2**(i))
print(res%(10**9+7))
