import sys


input = sys.stdin.readline

def main():
    N = int(input().rstrip())
    A = list(map(int, input().rstrip().split()))
    M = max(A).bit_length()
    B = [0] * (M + 1)
    p = 10 ** 9 + 7
    ans = 0

    for n in range(N):
        a = bin(A[n])
        l = len(a)
        for i, j in enumerate(reversed(a[2:])):
            B[i] += int(j)

    for i, b in enumerate(B):
        tmp = b * (N - b) * 2 ** i
        tmp %= p
        ans = ans + tmp
        ans %= p

    print(ans)


if __name__ == '__main__':
    main()