N,M = map(int,input().split())
modA = [a%M for a in map(int,input().split())]
ans = 0
for l in range(N):
  sumA = 0
  for r in range(l,N):
    sumA += modA[r]
    sumA = sumA%M
    if sumA%M == 0: ans += 1
print(ans)