mod=1000000007

ans=0

n=int(eval(input()))

a=[int(i) for i in input().split()]

x=[[0]*63 for i in range(n+1)]

l=[(2**i)%mod for i in range(63)]



for i in range(n):

    d=a[i]

    cnt=0

    for j in range(63):

        if d&1:

            x[i+1][cnt]=x[i][cnt]+1

        else:

            x[i+1][cnt]=x[i][cnt]

        cnt+=1

        d=d>>1



for i in range(1,n):

    for j in range(63):

        p=x[i][j]-x[i-1][j]

        if p:

            ans+=l[j]*((n-i)-(x[-1][j]-x[i][j]))

        else:

            ans+=l[j]*(x[-1][j]-x[i][j])

        ans%=mod

print(ans)
def sol():

    mod=1000000007

    ans=0

    n=int(eval(input()))

    a=[int(i) for i in input().split()]

    x=[[0]*63 for i in range(n+1)]

    l=[(2**i)%mod for i in range(63)]



    for i in range(n):

        d=a[i]

        cnt=0

        for j in range(63):

            if d&1:

                x[i+1][cnt]=x[i][cnt]+1

            else:

                x[i+1][cnt]=x[i][cnt]

            cnt+=1

            d=d>>1



    for i in range(1,n):

        for j in range(63):

            p=x[i][j]-x[i-1][j]

            if p:

                ans+=l[j]*((n-i)-(x[-1][j]-x[i][j]))

            else:

                ans+=l[j]*(x[-1][j]-x[i][j])

            ans%=mod

    print(ans)



if __name__=="__main__":

    sol()
mod = 1000000007
ans = 0
n = int(eval(input()))
a = [int(i) for i in input().split()]
x = [[0] * 63 for i in range(n + 1)]
l = [(2**i) % mod for i in range(63)]
for i in range(n):
    d = a[i]
    cnt = 0
    for j in range(63):
        if d & 1:
            x[i + 1][cnt] = x[i][cnt] + 1
        else:
            x[i + 1][cnt] = x[i][cnt]
        cnt += 1
        d = d >> 1
for i in range(1, n):
    for j in range(63):
        p = x[i][j] - x[i - 1][j]
        if p:
            ans += l[j] * ((n - i) - (x[-1][j] - x[i][j]))
        else:
            ans += l[j] * (x[-1][j] - x[i][j])
        ans %= mod
print(ans)

def sol():
    mod = 1000000007
    ans = 0
    n = int(eval(input()))
    a = [int(i) for i in input().split()]
    x = [[0] * 63 for i in range(n + 1)]
    l = [(2**i) % mod for i in range(63)]
    for i in range(n):
        d = a[i]
        cnt = 0
        for j in range(63):
            if d & 1:
                x[i + 1][cnt] = x[i][cnt] + 1
            else:
                x[i + 1][cnt] = x[i][cnt]
            cnt += 1
            d = d >> 1
    for i in range(1, n):
        for j in range(63):
            p = x[i][j] - x[i - 1][j]
            if p:
                ans += l[j] * ((n - i) - (x[-1][j] - x[i][j]))
            else:
                ans += l[j] * (x[-1][j] - x[i][j])
            ans %= mod
    print(ans)


if __name__ == "__main__":
    sol()

-mod = 1000000007 -ans = 0 -n = int(eval(input())) -a = [int(i) for i in input().split()] -x = [[0] * 63 for i in range(n + 1)] -l = [(2**i) % mod for i in range(63)] -for i in range(n): -    d = a[i] -    cnt = 0 -    for j in range(63): -        if d & 1: -            x[i + 1][cnt] = x[i][cnt] + 1 -        else: -            x[i + 1][cnt] = x[i][cnt] -        cnt += 1 -        d = d >> 1 -for i in range(1, n): -    for j in range(63): -        p = x[i][j] - x[i - 1][j] -        if p: -            ans += l[j] * ((n - i) - (x[-1][j] - x[i][j])) -        else: -            ans += l[j] * (x[-1][j] - x[i][j]) -        ans %= mod -print(ans) +def sol(): +    mod = 1000000007 +    ans = 0 +    n = int(eval(input())) +    a = [int(i) for i in input().split()] +    x = [[0] * 63 for i in range(n + 1)] +    l = [(2**i) % mod for i in range(63)] +    for i in range(n): +        d = a[i] +        cnt = 0 +        for j in range(63): +            if d & 1: +                x[i + 1][cnt] = x[i][cnt] + 1 +            else: +                x[i + 1][cnt] = x[i][cnt] +            cnt += 1 +            d = d >> 1 +    for i in range(1, n): +        for j in range(63): +            p = x[i][j] - x[i - 1][j] +            if p: +                ans += l[j] * ((n - i) - (x[-1][j] - x[i][j])) +            else: +                ans += l[j] * (x[-1][j] - x[i][j]) +            ans %= mod +    print(ans) + + +if __name__ == "__main__": +    sol()