N = int(input())
a = list(map(int,input().split()))
ma = max(a)
maketa = len(bin(ma))-2
print(maketa)
res = 0
for i in range(1,maketa+1):
    num = 0
    for j in range(N):
        num += a[j] % 2
        a[j] = a[j] // 2
    res += num*(N-num)*(2**(i-1))
print(res%(10**9+7))
