from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


length = int(fetch_one_line())
nums = fetch_int_input()

bit_nums = [bin(i)[2:] for i in nums]
max_length = max([len(i) for i in bit_nums])

def bai(i):
    i[0] *= 2
    i[0] = int(i[0])
    return i[0]

tmp = [1/2]
bit_nums = list(zip(*[list(i.zfill(max_length)) for i in bit_nums]))
sum_ones = [lst.count("1") for lst in bit_nums]
multiples = [i * (length - i) for i in sum_ones]

result = sum([bai(tmp) * m for m in reversed(multiples)])
print(result % (pow(10, 9) + 7))

