n,m = map(int,input().split())
a = list(map(int,input().split()))
sums = []
sum = 0
ans = 0

for i in range(n):
    sum += a[i]
    sums.append(sum)



dic = {}
for i in range(n):
    dic.setdefault(str(sums[i]%m),0)
    dic[str(sums[i]%m)] += 1
dic["0"]+= 1
#print(dic)

for key in dic.keys():
    k = dic[key]
    if k>1:
        ans += k*(k-1)//2

print(ans)
