N, M = map(int, input().split())
A = list(map(int, input().split()))
S = []
s = 0
for a in A:
    s += a
    S.append(s)

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

print(count)
