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