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