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