N,M = map(int,input().split())
A = [int(x) for x in input().split()]

ruiseki = []
a=0
for i in range(len(A)):
    a = a + A[i]
    ruiseki.append(a)

#print(ruiseki)
ruiseki_extra = ruiseki.copy()

for j in range(len(ruiseki) -1):
    for k in range(j+1,len(ruiseki)):
        #print(ruiseki[j],ruiseki[k])
        ruiseki_extra.append(abs(ruiseki[j] - ruiseki[k]))

#print(ruiseki_extra)

ans = 0
for l in range(len(ruiseki_extra)):
    if ruiseki_extra[l] % M == 0:
        ans += 1

print(ans)