fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val A = listOfInt()
    val map = mutableMapOf<Int, Int>()
    val sum = IntArray(N + 1)
    for (n in 0 until N) {
        sum[n + 1] = (sum[n] + A[n]) % M
    }
    var ans = 0
    for (n in 0 until sum.size) {
        val sum = map.get(sum[n]) ?: 0
        ans += sum
        map.put(sum[n], sum + 1)
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
