n,m = map(int,input().split())
A = list(map(int,input().split()))
from itertools import accumulate
A = list(accumulate([0]+A))
A = [a % m for a in A]

lst = [0 for i in range(m)]

for a in A:
  lst[a] += 1
  
def comb2(n):
  return n*(n-1)//2

ans = 0
for a in lst:
  ans += comb2(a)
print(ans)