import scala.io._
import scala.collection.mutable.Map

object Main extends App {
  val line1 = StdIn.readLine.split(' ')
  val n = line1(0).toInt
  val m = line1(1).toInt

  val as = StdIn.readLine.split(' ').map(_.toInt).toArray
  //
  // val n = 10000
  // val m = 400000000
  // val as = Array.fill(10000)(10000000000L)

  var memo: Map[(Int, Int), Long] = Map()
  // memo.put((1, 2), 3)
  //
  // println(memo)

  def get(from: Int, goal: Int): Long = {
    if (memo.contains(from, goal)) {
      memo(from, goal)
    } else {
      var sum: Long = 0
      for {
        i <- from to goal
      } {
        sum += as(i)
      }
      memo.put((from, goal), sum)
      sum
    }
  }

  var hoge = 0
  for {
    i <- 0 until n
    j <- i until n
  } {
    val sum = get(i, j)
    if (sum % m == 0) {
      hoge += 1
    }
    // println("%d, %d, %d".format(i, j, sum))
  }

  println(hoge)
  // println(strAry.sorted.mkString(" "))
}
