'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 cnt = {}
  let ret = 0
  let cur = 0
  for (let i = 0; i < N; i += 1) {
    cur = (cur + parseInt(A[i])) % M
    if (cur === 0) ret += 1
    if (typeof cnt[cur] === 'undefined') {
      cnt[cur] = 1
    } else {
      ret += cnt[cur]
      cnt[cur] += 1
    }
  }
  console.log(ret)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))