N=int(eval(input()))

A=list(map(int,input().split()))

bin_A=[bin(c) for c in A]

flags=[True]*N



count=0

for keta in range(60):

   count_0=0

   count_1=0

   for i in range(N):

      if flags[i]:

         if bin_A[i][-1*(keta+1)]=="b":

            count_0+=1

            flags[i]=False

         elif bin_A[i][-1*(keta+1)]=="0":

            count_0+=1

         else:

            count_1+=1

      elif flags[i]==False:

         count_0+=1

   count+=count_0*count_1*2**keta



print((count%(10**9+7)))
from sys import stdin

import numpy as np

def main():

    #入力

    readline=stdin.readline

    mod=10**9+7

    n=int(readline())

    a=list(map(int,readline().split()))

    a=np.array(a,dtype=np.int64)



    b=np.array([((a>>i)&1).sum() for i in range(61)],dtype=np.int64)

    c=np.full(61,n,dtype=np.int64)-b

    d=b*c

    d%=mod



    ans=0

    now=1

    for i in range(60):

        ans+=d[i]*now

        ans%=mod

        now*=2

        now%=mod



    print(ans)



if __name__=="__main__":

    main()
N = int(eval(input()))
A = list(map(int, input().split()))
bin_A = [bin(c) for c in A]
flags = [True] * N
count = 0
for keta in range(60):
    count_0 = 0
    count_1 = 0
    for i in range(N):
        if flags[i]:
            if bin_A[i][-1 * (keta + 1)] == "b":
                count_0 += 1
                flags[i] = False
            elif bin_A[i][-1 * (keta + 1)] == "0":
                count_0 += 1
            else:
                count_1 += 1
        elif flags[i] == False:
            count_0 += 1
    count += count_0 * count_1 * 2**keta
print((count % (10**9 + 7)))

from sys import stdin
import numpy as np


def main():
    # 入力
    readline = stdin.readline
    mod = 10**9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    a = np.array(a, dtype=np.int64)
    b = np.array([((a >> i) & 1).sum() for i in range(61)], dtype=np.int64)
    c = np.full(61, n, dtype=np.int64) - b
    d = b * c
    d %= mod
    ans = 0
    now = 1
    for i in range(60):
        ans += d[i] * now
        ans %= mod
        now *= 2
        now %= mod
    print(ans)


if __name__ == "__main__":
    main()

-N = int(eval(input())) -A = list(map(int, input().split())) -bin_A = [bin(c) for c in A] -flags = [True] * N -count = 0 -for keta in range(60): -    count_0 = 0 -    count_1 = 0 -    for i in range(N): -        if flags[i]: -            if bin_A[i][-1 * (keta + 1)] == "b": -                count_0 += 1 -                flags[i] = False -            elif bin_A[i][-1 * (keta + 1)] == "0": -                count_0 += 1 -            else: -                count_1 += 1 -        elif flags[i] == False: -            count_0 += 1 -    count += count_0 * count_1 * 2**keta -print((count % (10**9 + 7))) +from sys import stdin +import numpy as np + + +def main(): +    # 入力 +    readline = stdin.readline +    mod = 10**9 + 7 +    n = int(readline()) +    a = list(map(int, readline().split())) +    a = np.array(a, dtype=np.int64) +    b = np.array([((a >> i) & 1).sum() for i in range(61)], dtype=np.int64) +    c = np.full(61, n, dtype=np.int64) - b +    d = b * c +    d %= mod +    ans = 0 +    now = 1 +    for i in range(60): +        ans += d[i] * now +        ans %= mod +        now *= 2 +        now %= mod +    print(ans) + + +if __name__ == "__main__": +    main()