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


S = [0]
for i in range(1, N + 1):
    S.append(A[i - 1] + S[i-1])


ans = 0
for l in range(0, N):
    for r in range(l + 1, N + 1):
        if (S[r] - S[l]) % M == 0:
            ans += 1


print(ans)
