import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int64)

LARGE = 10 ** 9 + 7

shift = 0
total = 0
while A.any():
    bits = (A & 1).sum()
    total += (bits * (N - bits)) << shift
    A >>= 1
    shift += 1

print(total % LARGE)
