### BUGGY CODE ###

def solve(a_s) -> int:
  def get_ret_from_xs(xs) -> int:
    # 繰り上がり処理ありバージョン
    ret = 0
    for i, x in enumerate(xs):
      ret += 2**i * (x % 2)
      ret %= 10**9 + 7
    return ret

  def get_ret_from_xs2(xs) -> int:
    ret = 0
    for i, x in enumerate(xs):
      ret += 2**i * x
      ret %= 10**9 + 7
    return ret

  # zeros = [1, 1] + [0] * 58  # 各要素 0 ~ n. 要素iは、下 i +1 桁目が0である A_? の個数
  # ones = [2, 2] + [0] * 58 # 各要素 0 ~ n. 要素iは、下 i +1 桁目が0である A_? の個数
  zeros = [0] * 60

  for a in a_s:
    for i in range(len(zeros)):
      # a_bin = format(a, '060b')
      # a_i_digit_from_right = a_bin[60 - i - 1]
      # if a_i_digit_from_right == '0':
      #   zeros[i] += 1
      # else:
      #   ones[i] += 1

      a_i_digit_from_right = ((a & (2**i)) >> i) & 0b1
      if a_i_digit_from_right == 0:
        zeros[i] += 1

  # 繰り上がり処理しないでも、各桁で収めてもいいんだ！
  xs = [zeros[i] * (len(a_s) - zeros[i]) for i in range(60)]
  return get_ret_from_xs2(xs)


  # # 繰り上がりのせいで、xsの要素数は60を超えることがあるので注意
  # xs = []
  # i = 0
  # while True:
  #   x_i = 0
  #   if i <= 59:
  #     x_i = (zeros[i] * ones[i])
  #   if i >= 1:
  #     x_i += xs[i - 1] // 2
  #   xs.append(x_i)
  #
  #   if i >= 60 and x_i // 2 == 0:
  #     break
  #
  #   i += 1

  #xs = [2, 3, 1]
  #return get_ret_from_xs(xs)


n = int(input().strip())
a_s = [int(s) for s in input().split()]

#a_s = [1, 2, 3]
#a_s = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
#a_s = [3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820]

print(solve(a_s))



### FIXED CODE ###

def solve(a_s) -> int:
  # def get_ret_from_xs(xs) -> int:
  #   # 繰り上がり処理ありバージョン
  #   ret = 0
  #   for i, x in enumerate(xs):
  #     ret += 2**i * (x % 2)
  #     ret %= 10**9 + 7
  #   return ret
  #
  # def get_ret_from_xs2(xs) -> int:
  #   ret = 0
  #   for i, x in enumerate(xs):
  #     ret += 2**i * x
  #     ret %= 10**9 + 7
  #   return ret

  # zeros = [1, 1] + [0] * 58  # 各要素 0 ~ n. 要素iは、下 i +1 桁目が0である A_? の個数
  # ones = [2, 2] + [0] * 58 # 各要素 0 ~ n. 要素iは、下 i +1 桁目が0である A_? の個数
  zeros = [0] * 60

  ret = 0
  for i in range(60):
    ones = sum([(a >> i) & 0b1 for a in a_s])
    ret += 2**i * (ones * (len(a_s) - ones))
    ret %= 10**9 + 7
  return ret

  # for a in a_s:
  #   for i in range(len(zeros)):
  #     # a_bin = format(a, '060b')
  #     # a_i_digit_from_right = a_bin[60 - i - 1]
  #     # if a_i_digit_from_right == '0':
  #     #   zeros[i] += 1
  #     # else:
  #     #   ones[i] += 1
  #
  #     a_i_digit_from_right = (a >> i) & 0b1
  #     if a_i_digit_from_right == 0:
  #       zeros[i] += 1
  #
  # # 繰り上がり処理しないでも、各桁で収めてもいいんだ！
  # xs = [zeros[i] * (len(a_s) - zeros[i]) for i in range(60)]
  # return get_ret_from_xs2(xs)
  #
  #
  # # # 繰り上がりのせいで、xsの要素数は60を超えることがあるので注意
  # # xs = []
  # # i = 0
  # # while True:
  # #   x_i = 0
  # #   if i <= 59:
  # #     x_i = (zeros[i] * ones[i])
  # #   if i >= 1:
  # #     x_i += xs[i - 1] // 2
  # #   xs.append(x_i)
  # #
  # #   if i >= 60 and x_i // 2 == 0:
  # #     break
  # #
  # #   i += 1
  #
  # #xs = [2, 3, 1]
  # #return get_ret_from_xs(xs)


n = int(input().strip())
a_s = [int(s) for s in input().split()]

#a_s = [1, 2, 3]
#a_s = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3]
#a_s = [3, 14, 159, 2653, 58979, 323846, 2643383, 27950288, 419716939, 9375105820]

print(solve(a_s))