import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**5)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


import numpy as np


def main():
    n = gete(int)
    a = np.array(list(geta(int)))
    a.sort()
    mod = 10**9 + 7
    ans = 0

    base = 1
    while a[-1] > 0:
        b = a & 1
        ones = b.sum()
        ans += ones * (n - ones) * base
        ans %= mod
        a = a >> 1
        base = base * 2 % mod

    print(ans)


if __name__ == "__main__":
    main()