import numpy as np
import math
n = int(input())
A = np.fromstring(input(),dtype=np.int64,sep=" ")
rng = int(math.log2(np.max(A)))+1
sum = 0
for bit in range(rng):
    c = (A & 1).sum()
    sum += c *(n-c)*(2**bit)
    A = A>>1

print(sum %(10**9+7))
