object Main extends App {
  val n = io.StdIn.readLine().toInt
  val m = (1e9+7).toInt
  val an = io.StdIn.readLine().split(' ').map(_.toLong)
  var sum: Long = 0
  var b: BigInt = 1
  val max = an.max
  while (b <= max) {
    var (z, o) = (0, 0)
    an.indices foreach {i =>
      if ((an(i) & 1) == 0) z += 1 else o += 1
      an(i) = an(i) >> 1
    }
    sum += ((b*z*o) % m).toLong
    sum %= m
    b = b << 1
  }
  println(sum)
}