print("reference: maspy")

from collections import Counter
 
N, M = map(int, input().split())
A = list(map(int, input().split()))

S = [0] * N
for i in range(N):
  S[i] = (S[i-1] + A[i]) % M
print(S)
  
# 累積和で引くから、同じものを数えればいい。
c = Counter(S)
print(c)

answer = 0
for x in c.values():
  #print(x)
  answer += x * (x - 1) // 2
print(answer)