object Main extends App {
  io.StdIn.readLine()
  val numbers = io.StdIn.readLine().split(' ').map(_.toLong).toList
  
  val divider = math.pow(10, 9).toLong + 7L
  
  def sumxor(rest: List[Long], acc: Long): Long = rest match {
    case x :: Nil => acc
    case x :: xs =>
    	sumxor(xs, (acc + xs.map(_ ^ x).foldLeft(0L) {
          case (sum, elem) => (sum + elem) % divider
        }) % divider)
    case _ => throw new Exception("想定外のデータです")
  }
  
  val answer = sumxor(numbers, 0L)
  println(answer)
}