from collections import defaultdict as dd

def main():
  N = int(input())
  A = list(map(int, input().split()))
  MOD = 10 ** 9 + 7
  ones = dd(int)
  for a in A:
    for i in range(60):
      if (a >> i) & 1 == 1:
        ones[i] += 1

  res = 0
  for a in A:
    for i in range(60):
      if (a >> i) & 1 == 0:
        res += ones[i] * 2 ** i
      else:
        res += (N-ones[i]) * 2 ** i
        ones[i] -= 1
      res %= MOD
  
  print(res)
if __name__ == "__main__":
    main()