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)

ans = 0
for a in range(0,len(ruiseki)):
    if ruiseki[a] % M == 0:
        ans += 1

for j in range(0,len(ruiseki)):
    for h in range(1,len(ruiseki)):
        if j + h < len(ruiseki):
            #print(ruiseki[j+h] - ruiseki[j])
            if (ruiseki[j+h] - ruiseki[j]) % M == 0:
                ans += 1
        else:
            break

#print("kotae")
print(ans)