import numpy as np

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

head=0
B=np.zeros(M)
B[0]=1
for a in A:
    head += a
    B[head%M]+=1
ans=0
for b in B:
    ans += b*(b-1)/2
print(int(ans))