N, M = map(int, input().split())
A = [int(i) for i in input().split()]

S = [0 for _ in range(N+1)]

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

ans = 0
for j in range(N+1):
    for i in range(j):
        if (S[j]-S[i]) % M == 0:
            ans += 1

print(ans)
