N,M =map(int,input().split())
A = [0] + list(map(lambda x: int(x)%M,input().split()))
for i in range(N):
  A[i+1] = (A[i]+A[i+1])%M
ans = 0
for l in range(N):
  for d in range(N-l):
    if (A[l+d+1]-A[l])%M == 0:
      ans += 1
print(ans)