def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

# numpy and scipy are available for use
import numpy
import scipy
#https://atcoder.jp/contests/abc147/tasks/abc147_d
#Xor Sum 4
"""
iterate over bits
1. calculate how many bits we have on that position
2. for each 1, we need to add num 0s * num 1s * 2s
3. sum them up

This version has TLE
"""

# reads a single line
N = gi()
a = [0] * N

max_v = 0
for i in range(N):
    a[i] = gi()
    max_v = max(max_v, a[i])

ans = 0
for shift in range(60):
    base = 1 << shift
    if (base > max_v):
        break
    n1 = 0
    for ai in a:
        if (ai & base):
            n1 += 1

    part = n1 * (N - n1)
    part %= MOD
    part *= base
    part %= MOD
    ans += part
    ans %= MOD

print(ans)
