import sequtils, strutils, algorithm, math

var N = stdin.readline.parseInt
var A = stdin.readline.split.map(parseInt)

var MOD = 10^9+7
var bits = newSeqWith(60,0)
var ans = 0

var c = 0
for j in countdown(N-1,1):
  for b in 0..<60:
    if (A[j] and (1 shl b)) != 0:
      bits[b] += 1
  c += 1

  var sh = 1
  for b in 0..<60:
    var flag = (A[j-1] and (1 shl b)) != 0

    if(flag):
      ans += ((c-bits[b]) * sh) mod MOD
    else:
      ans += (bits[b] * sh) mod MOD

    ans = ans mod MOD     
    sh = (sh shl 1)

echo ans
