import numpy as np

N = int(input())
As = list(map(int, input().split()))

pure_total = sum(As)
# pure_total = 0

sabun_mat = np.zeros((N, 60), np.int)

# exp2total = {}
for i in range(60):
    tmp_total = 0
    for j, a in enumerate(As[::-1]):
        tmp_total += (2**i ^ a) - a
        sabun_mat[N-1-j, i] = tmp_total
    # exp2total[i] = tmp_total

# print(sabun_mat)
total = 0
for i, a in enumerate(As[:-1]):
    pure_total -= a
    total += pure_total
    # print(bin(a))
    for j,b in enumerate(bin(a)[2:][::-1]):
        # print("b",b)
        # print("type", type(b))
        if b == "1":
            total += sabun_mat[i+1, j]
            # print(sabun_mat[i, j])
            # print()

print(int(total) % (10**9+7))