fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val a = ("0 "+readLine()!!).split(" ").map { it.toLong() }.toLongArray()
    for(i in 1..a.lastIndex) a[i]+=a[i-1]
    a.groupBy { it%m }
            .map { it.value.size }
            .filter { it>=2 }
            .map { it*(it-1L)/2 }
            .sum()
            .let { println(it) }
}