from collections import defaultdict

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

S = [0]*(N+1)
S[0] = 0
for i in range(1, N):
  S[i] = (S[i-1] + A[i-1]) % M

d = defaultdict(int)
ans = 0
for i in range(len(S)):
  ans += d[S[i]]
  d[S[i]] += 1
print(ans)