N,M=input().split()
N =int(N)
M =int(M)
a= list(map(int,input().split()))
dict={}
ans = 0
p = 0
dict[0] = 1
for i in range(N):
    p = (p+a[i])%M
    if p not in dict:
        dict[p] = 1
    else:
        ans +=dict[p]
        dict[p] += 1
print(ans)
