from collections import Counter
from itertools import accumulate
N,M=map(int,input().split())
print(sum( (s*(s-1))//2  for s in Counter((i%M for i  in accumulate([0]+[int(i) for i in input().split()]))).values()))