N = int(input())
A = list(map(int, input().split()))
INF = 1000000007
keta = len(bin(max(A))) - 2
ans = 0
shift = 0
num_1 = 0
for _ in range(keta):
    
    for a in A:
       num_1=1 if a>>shift&1 else 0
    ans += num_1 * (N-num_1) * 2 ** shift
    shift += 1
print(ans % INF)