#22:07
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = [0]
for i in range(n):
  b.append((b[-1]+a[i])%m)
b.sort()
#print(b)
ans = 0
tmp = 0
for i in range(1,n+1):
  if b[i-1] == b[i]:
    tmp += 1
  else:
    tmp = 0
  ans += tmp
print(ans)