N = int(input())
A = [int(N) for N in input().split()]
max_size = len(format(max(A),"b"))
A_bin = list(map(lambda x: format(x,"b").zfill(max_size), A))


bin2dec = 1
result = 0


for i in range(max_size):
    zero = 0
    one = 0
    for j in A_bin:
        if j[max_size-1-i] == "0":
            zero += 1
        else:
            one += 1
    result += (bin2dec * zero * one) %1000000007
    bin2dec *= 2 %1000000007


print(result%1000000007)