import sys

read = sys.stdin.read



def main():

  MOD = 10**9+7

  n, *A = list(map(int, read().split()))

  ans = 0

  for j in range(61):

    c = 0

    for i in A:

      if i>>j & 1:

        c += 1

    ans += 2**j*((n-c)*c)

    ans %= MOD

  print((ans%MOD))

  

if __name__ == "__main__":

  main()
import sys

input = sys.stdin.readline



import numpy as np



def main():

  MOD = 10**9+7

  n = int(eval(input()))

  A = np.array(input().split(), dtype=np.int64)

  ans = 0

  for j in range(61):

    X = A>>j & 1

    t = np.count_nonzero(X)

    ans += pow(2, j, MOD) * t * (n-t) % MOD

  print((ans%MOD))

  

if __name__ == "__main__":

  main()
import sys

read = sys.stdin.read


def main():
    MOD = 10**9 + 7
    n, *A = list(map(int, read().split()))
    ans = 0
    for j in range(61):
        c = 0
        for i in A:
            if i >> j & 1:
                c += 1
        ans += 2**j * ((n - c) * c)
        ans %= MOD
    print((ans % MOD))


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline
import numpy as np


def main():
    MOD = 10**9 + 7
    n = int(eval(input()))
    A = np.array(input().split(), dtype=np.int64)
    ans = 0
    for j in range(61):
        X = A >> j & 1
        t = np.count_nonzero(X)
        ans += pow(2, j, MOD) * t * (n - t) % MOD
    print((ans % MOD))


if __name__ == "__main__":
    main()

-read = sys.stdin.read +input = sys.stdin.readline +import numpy as np -    n, *A = list(map(int, read().split())) +    n = int(eval(input())) +    A = np.array(input().split(), dtype=np.int64) -        c = 0 -        for i in A: -            if i >> j & 1: -                c += 1 -        ans += 2**j * ((n - c) * c) -        ans %= MOD +        X = A >> j & 1 +        t = np.count_nonzero(X) +        ans += pow(2, j, MOD) * t * (n - t) % MOD