import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = println(solve(new Scanner(System.in)))

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val M = sc.nextInt
    val A = Array.fill(N)(sc.nextInt)

    // Ai までの累積の余りを出す
    val s = ArrayBuffer.fill(N + 1)(0)
    s(0) = 0
    var sum = 0
    for (i <- 0 until N) {
      sum += A(i)
      sum %= M
      s(i + 1) = sum
    }

    var ans = 0
    val r = ArrayBuffer.fill(M)(0)
    for (i <- 0 to N) {
      ans += r(s(i))
      r(s(i)) += 1
    }
    ans.toString
  }
}
