N,M=map(int,input().split())
A=list(map(int,input().split()))
aa = [0]*(N+1)
for i in range(N):
  aa[i+1] = aa[i]+A[i]
cnt = 0
for l in range(N):
  for r in range(l,N):
    if (aa[r+1]-aa[l])%M == 0:
      cnt += 1
print(cnt)
