# -*- 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)
next_skip = False

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

print(p)