N,*A = `dd`.split.map &:to_i
s = 0
t = 1
60.times {
  nsub = [0,0]
  (0...N).reverse_each{ |i|
    a = A[i] % 2
    s += nsub[1 - a] * t
    nsub[a] += 1
    A[i] /= 2
  }
  t *= 2
}
p s % (10 ** 9 + 7)
