import sys
input = sys.stdin.readline

def main():
    N = int(input())
    *A, = map(int, input().split())
    ans = 0
    B = [0] * 61
    for k, a in enumerate(A):
        *la, = map(int, list(bin(a))[2:])
        j = 0
        for i in range(61-len(la), 61):
            B[i] += la[j]
            j += 1

    ans = 0
    mod = 10**9 + 7
    for i, b in enumerate(B):
        ans += b * (len(A)-b) * 2**(60-i) % mod
    print(ans % mod)


if __name__ == "__main__":
    main()
