import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    mod = 7 + 10 ** 9

    bit = [0 for _ in range(60)] 

    last = A[N-1]
    for j in range(60):
        bit[j] = last % 2
        last //= 2
    
    ans = 0
    for i in reversed(range(N-1)):
        total = N - 1 - i
        num = A[i]
        for j in range(60):
            if num % 2 == 1:
                ans += (total - bit[j]) * pow(2, j, mod)
                ans %= mod
            else:
                ans += bit[j] * pow(2, j, mod)
                ans %= mod
            bit[j] += (num % 2)
            num //=2
    print(ans)

    return 0

if __name__ == "__main__":
    solve()