MOD = 10 ** 9 + 7
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [0] * 60
    for i in A:
        for j in range(60):
            if i & (1 << j):
                B[j] += 1
    print(B[:5])
    r = 0
    for ii, i in enumerate(A[:-1]):
        for j in range(60):
            if i & (1 << j):
                B[j] -= 1
            if i & (1 << j):
                r += (1 << j) * (N - ii - 1 - B[j])
            else:
                r += (1 << j) * B[j]
            r = r % MOD
    print(r)

main()
