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