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

S = [0] * (N+1)
for i in range(N) :
    S[i+1] = S[i] + A[i]

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

print(ans)

