# coding: utf-8
from collections import defaultdict

N,M=map(int,input().split())
A=list(map(int,input().split()))

B=[0]

s=0
for a in A:
    s+=a
    B.append(s)
F=defaultdict(int)
for b in B:
    F[b%M]+=1
ans=0
for n in F.values():
    ans+=n*(n-1)//2
print(ans)