import collections
n,m=map(int,input().split())
l=list(map(int,input().split()))
L=[l[0]%m]
for i in range(1,n):
  L.append((L[i-1]+l[i])%m)
L.append(0)
L=collections.Counter(L)

ct=0
for i in L.values():
  ct+=i*(i-1)//2
print(ct)