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: BigInt = 0
  var b: BigInt = 1
  val max = an.max
  while (b <= max) {
    val (z,o) = an.foldLeft((0,0)){case ((zero,one), l) => if ((l & b) == 0) (zero+1, one) else (zero, one+1)}
    sum += (b*z*o) % m
    sum %= m
    b = b << 1
  }
  println(sum)
}