import numpy as np

import sys



def main():

  input = sys.stdin.readline

  n = int(eval(input()))

  a = np.array([int(x) for x in input().split()])

  inf = pow(10, 9)+7

  max_a = np.max(a)

  bit = 1

  ans = 0

  num = 0

  while max_a:

    num += 1

    max_a //= 2

  for _ in range(num):

    bit_count = np.sum(a%2)

    ans += ((((bit_count%inf)*((n-bit_count)%inf))%inf)*(bit%inf))%inf

    ans %= inf

    a //= 2

    bit *= 2

  print(ans)

  

if __name__ == "__main__":

  main()
import numpy as np



n = int(eval(input()))

a = np.array([int(x) for x in input().split()])



ans = 0

mod = pow(10, 9)+7

for i in range(100):

  c = np.sum((a>>i)&1)

  ans += (c*(n-c)%mod)*pow(2, i, mod)%mod

  ans %= mod



print(ans)
import numpy as np
import sys


def main():
    input = sys.stdin.readline
    n = int(eval(input()))
    a = np.array([int(x) for x in input().split()])
    inf = pow(10, 9) + 7
    max_a = np.max(a)
    bit = 1
    ans = 0
    num = 0
    while max_a:
        num += 1
        max_a //= 2
    for _ in range(num):
        bit_count = np.sum(a % 2)
        ans += (
            (((bit_count % inf) * ((n - bit_count) % inf)) % inf) * (bit % inf)
        ) % inf
        ans %= inf
        a //= 2
        bit *= 2
    print(ans)


if __name__ == "__main__":
    main()

import numpy as np

n = int(eval(input()))
a = np.array([int(x) for x in input().split()])
ans = 0
mod = pow(10, 9) + 7
for i in range(100):
    c = np.sum((a >> i) & 1)
    ans += (c * (n - c) % mod) * pow(2, i, mod) % mod
    ans %= mod
print(ans)

-import sys - -def main(): -    input = sys.stdin.readline -    n = int(eval(input())) -    a = np.array([int(x) for x in input().split()]) -    inf = pow(10, 9) + 7 -    max_a = np.max(a) -    bit = 1 -    ans = 0 -    num = 0 -    while max_a: -        num += 1 -        max_a //= 2 -    for _ in range(num): -        bit_count = np.sum(a % 2) -        ans += ( -            (((bit_count % inf) * ((n - bit_count) % inf)) % inf) * (bit % inf) -        ) % inf -        ans %= inf -        a //= 2 -        bit *= 2 -    print(ans) - - -if __name__ == "__main__": -    main() +n = int(eval(input())) +a = np.array([int(x) for x in input().split()]) +ans = 0 +mod = pow(10, 9) + 7 +for i in range(100): +    c = np.sum((a >> i) & 1) +    ans += (c * (n - c) % mod) * pow(2, i, mod) % mod +    ans %= mod +print(ans)