MOD = 10 ** 9 + 7


def solve(n, a):
    m = 62
    b = [('0'*m + bin(a[i])[2:])[-1:-m:-1] for i in range(n)]
    cnt_bit = [0] * m
    for i in range(n):
        for j, c in enumerate(b[i]):
            if c == '1':
                cnt_bit[j] += 1
    total = 0
    for i in range(n):
        for j, c in enumerate(b[i]):
            if c == '0':
                total += 2 ** j * cnt_bit[j]
            if c == '1':
                total += 2 ** j * (n - cnt_bit[j])
    return (total//2) % MOD


def bf(n, a):
    total = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            total += (a[i] ^ a[j])
    return total % MOD


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    print(solve(n, a))
    # print(bf(n, a))
