import bisect
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
N,M = map(int,readline().split())
A = np.array(readline().split(),np.int64)
#print(A)
C = np.cumsum(A)
#print(C)
ans = np.sum(C % M == 0)
for i in range(N-1):
  C -= A[i]
  C = C[1:]
  #print(C)
  ans += np.sum(C % M == 0)
print(ans)