import java.util.Scanner

import scala.collection.mutable

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)

    val checked = mutable.Set[Int](N)
    var ans = 0L
    for (l <- 0 until N if !checked(l)) {
      var sum = 0
      var r = 0
      for (i <- l until N) {
        if (sum == 0) {
          checked += i
        }
        sum += A(i)
        if (sum % M == 0) {
          r += 1
          ans += r
          sum = 0
        }
      }
    }
    ans.toString
  }
}
