from collections import Counter
n,m = (int(x) for x in input().split())
a = list(map(int, input().split()))
s = [0]*(n+1)
for i in range(1,n+1):
  s[i] = (s[i-1] + a[i-1])%m

cl = Counter(s).values()
ans = sum(i*(i-1)//2 for i in cl)
print(ans)


