# -*- coding: utf-8 -*-
import numpy as np
import math
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))

p = 0
flag = np.repeat(0, N)
for i_start in range(N):
  if flag[i_start] == 1:
    continue
  A_ = np.cumsum(A[i_start:])
  A_ = np.concatenate([[0], A_])
  A_ = A_ % M
  flag[i_start] = 1
  n_zero = np.sum(A_ == 0)
  if n_zero == 1:
    continue
  else:
    for j in range(1, len(A_) - 1):
      if A_[j] == 0:
        flag[i_start + j] = 1
    p = p + math.factorial(n_zero) // (math.factorial(n_zero - 2) * 2)

print(p)