N, M = map(int, input().split())
As = list(map(int, input().split()))
s = 0
Ss = [0]
for A in As:
  s += A
  Ss.append(s%M)
r = 0
Cs = {}
for s in Ss:
  if not(s in Cs):
    Cs[s] = 0
  r += Cs[s]
  Cs[s] += 1
print(r)
