from itertools import accumulate

n, m = map(int, input().split())
A = list(map(int, input().split()))
dp = [ [0]*(n+1) for _ in range(n+1) ]
L = [0] + list(accumulate(A))
ans = 0
for i in range(1, n+1):
  for j in range(i):
    if (L[i]-L[j])%m == 0:
      ans += 1
print(ans)