from collections import Counter
N,M=map(int,input().split())
a=list(map(int,input().split()))
s=[a[0]]
for i in range(N-1):
    s.append(s[i]+a[i+1])
for i in range(N):
    s[i]%=M
count=0
b=Counter(s)
c=b.most_common()
def calc(n):
    ans=0
    for i in range(1,n+1):
        ans+=i
    return ans
for i in range(len(c)):
    if c[i][1]!=1:
        count+=calc(c[i][1]-1)
        if c[i][0]==0:
            count+=c[i][1]
    else:
        break
print(count)