N = int(input())
A = list(map(int, input().split()))
MOD = 1000000007

for i, a in enumerate(A):
    if i == 0:
        bits = [[0] * 60]
    else:
        bits.append(bits[i - 1].copy())

    cnt = 0
    while a != 0:
        if a & 1:
            bits[i][cnt] += 1

        cnt += 1
        a >>= 1


all_sum = 0
for i, a in enumerate(A):
    temp_sum = 0
    cnt = 0
    while cnt < 60:
        ones = bits[-1][cnt] - bits[i][cnt]
        zeros = N - (i + 1) - ones

        if a & 1:
            temp_sum += (pow(2, cnt, MOD) * zeros) % MOD
        else:
            temp_sum += (pow(2, cnt, MOD) * ones) % MOD

        temp_sum %= MOD

        a >>= 1
        cnt += 1

    all_sum += temp_sum
    all_sum %= MOD


print(all_sum)

