'use strict'
function Main(input) {
  input = input.split("\n")
  let line1 = input[0].split(' ')
  let N = parseInt(line1[0])
  let M = parseInt(line1[1])
  let A = input[1].split(' ')
  let preSum = []
  let ret = 0
  preSum.push(0)
  for (let i = 1; i <= N; i += 1) preSum.push((preSum[i - 1] + A[i - 1] % M) % M)
  for (let i = 1; i <= N; i += 1) {
    for (let j = i; j <= N; j += 1) {
      if ((preSum[j] - preSum[i - 1] + M) % M === 0) ret += 1
    }
  }
  console.log(ret)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))