fun main(arr:Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val items = readLine()!!.split(" ").map { it.toLong() }
    val cntList = mutableListOf(items[0] % m)
    for(i in (1 until n)) {
        cntList.add((cntList.last() + items[i])%m)
    }
    val cnt = mutableMapOf<Long, Int>()
    for(i in cntList) {
        if(cnt.containsKey(i)) {
            cnt[i] = cnt[i]!! + 1
        } else {
            cnt[i] = 1
        }
    }
    val ans = cnt.values.map { it*(it-1)/2 }.sum() + (cnt[0L]?:0)
    println(ans)
}
