fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val a = readLine()?.split(" ")?.map(String::toLong) ?: return

    val mod = (1e9 + 7).toLong()
    var total = 0L

    0.until(n - 1).forEach { i ->
        (i + 1).until(n).forEach { j ->
            total = (total + (a[i] xor a[j])) % mod
        }
    }
    println(total.toString())
}