N, M = map(int, input().split())
Ain = list(map(int, input().split()))
B = []
B.append(Ain[0])
for i, a in enumerate(Ain[1::]):
    B.append(a + B[i])
B.append(0) # A[-1]

B = [x%M for x in B]

ans = 0
for l in range(N):
    for r in range(l,N):
        ans += B[r] == B[l-1]
print(ans)