N, M = [int(str) for str in input().strip().split()]
A = [int(str) for str in input().strip().split()]

sums = [0]
for i in range(N):
    sums.append(sums[-1] + A[i])
    if sums[i] > M:
        sums[i] -= M

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

print(ans)