import numpy as np


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

sums = np.zeros(N + 1)
for i in range(1, N):
    sums[i] = sums[i - 1] + A[i]

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

print(ans)