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
    p = 10 ** 9 + 7
    ans = 0

    for n in range(N):
        a = bin(A[n])[:1:-1]
        l = len(a)
        for i in range(l):
            B[i] += int(a[i])

    for m in range(M):
        tmp = B[m] * (N - B[m]) * 2 ** m
        tmp %= p
        ans = ans + tmp
        ans %= p

    print(ans)


if __name__ == '__main__':
    main()