fun main(args : Array<String>) {
    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val A = readLine()!!.split(" ").map { it.toInt() % M }.toIntArray()
    var answer = 0L
    (1 until N).forEach {
        A[it] = (A[it] + A[it - 1])% M
    }

    val countMap = hashMapOf<Int, Long>()
    A.forEach {
        if (countMap[it] == null) {
            countMap[it] = 1
        } else {
            countMap[it] = countMap[it]!! + 1
        }
    }

    if (countMap[0] != null) {
        answer += countMap[0]!!
    }
    countMap.entries.forEach {
        val (num, size) = it
        if (size > 1) {
            answer += size * (size - 1) / 2
        }
    }

    println(answer)
}
