N, M = map(int, input().split())
A_s = list(map(int,input().split()))

B_s = [sum(A_s[0:i+1]) for i in range(N)]
B_s = [B_s[i] % M for i in range(N)]

B_s = [sum(x==i for x in B_s)  for i in range(M)]
print(sum(B_s))