fun main(args: Array<String>) {
    val num = 64
    fun toBinaryNumberString(input: Long): String {
        return ((0 until num).map { "0" }.joinToString("") + java.lang.Long.toBinaryString(input)).takeLast(num)
    }

    val mod = 1000000007L
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { toBinaryNumberString(it.toLong()).reversed() }
    val sumArray = Array(num) { 0L }
    (0 until num).forEach {
        for (i in 0 until n) {
            sumArray[it] += aList[i][it].toString().toLong()
        }
    }
    var ans = 0L
    (0 until num).forEach {
        ans += (((sumArray[it] * (n - sumArray[it])) % mod)
                * Math.pow(2.toDouble(), it.toDouble()).toLong() % mod) % mod
        ans %= mod
    }
    println(ans)
}