N, M = map(int, input().split())
A = list(map(int, input().split()))
S = [0 for _ in range(N + 1)]
for i in range(1, N + 1):
    S[i] = S[i - 1] + A[i - 1]
ans = 0
for l in range(N):
    for r in range(l, N):
        s = S[r + 1] - S[l]
        if s % M == 0:
            ans += 1
print(ans)