# coding: utf-8
# Your code here!

import collections

n,m=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]

S=[0]*(n+1)
for i in range(n):
    S[i+1]=(S[i]+A[i])%m

c = collections.Counter(S)

ans=0
for i in c:
    ans+=c[i]*(c[i]-1)//2

print(c)
print(ans)    
    