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

com_sum = [0] * (N+1)
for i in range(N):
    com_sum[i+1] = A[i] + com_sum[i]
ans = 0
for i in range(N):
    for j in range(i+1, N+1):
        if (com_sum[j] - com_sum[i]) % M == 0:
            ans += 1
print(ans)
