import numpy as np

N, M = list(map(int,input().split()))
A = np.array(list(map(int,input().split())))

A_mod = A % M

re = 0
if sum(A_mod) < M and np.where(A < M) > 0: # 余りの合計がM以下でAの要素がそもそもM以下
    re = 0
else:
    for i in range(N):
        for j in range(i, N):
            if sum(A[i:j+1]) % M == 0:
                re += 1

print(re)