from collections import Counter
n,m = map(int,input().split())
l = list(map(int,input().split()))
mod = [0]
for i in l:
    mod.append((mod[-1]+i)%m)

c = Counter(mod)
ans = 0
for i in c.values():
    ans += i*(i-1)//2
print(ans)
