n,m=map(int,input().split())
a=list(map(lambda x:int(x)%m,input().split()))

ans=0
sup=[0]
sm=0
for i in range(n):
    sm += a[i]
    sm %= m
    sup.append(sm)

supL=[]
supN=[]
for i in range(n+1):
    if sup[i] in supL:
        ind=supL.index(sup[i])
        supN[ind] += 1
    else:
        supL.append(sup[i])
        supN.append(1)
for i in supN:
    ans += i*(i-1)//2

print(ans)