N,M = map(int, input().split())
L = list(map(int, input().split()))
import itertools as it
L=[0]+list(map(lambda x : x % M,it.accumulate(L)))
S=sorted(L)
#print(S)
tmp = -1
ans = 0
cnt=0
def nC2(n):
    return int(n*(n-1)/2)
for x in S:
    
    if tmp == x:
        cnt += 1
    else:
        ans += nC2(cnt+1)
        cnt = 0
    tmp = x
print(ans)