import collections,itertools
n,m = map(int,input().split())
s = [0]
s.extend(itertools.accumulate(map(int,input().split())))
s = collections.Counter(a%m for a in s)
print(sum(v*(v-1)//2 for v in s.values()))
