from collections import defaultdict
import itertools

N, M = map(int, input().split())
a = [0]+list(itertools.accumulate(map(int, input().split())))

d = defaultdict(int)
for i in a:
    d[i%M] += 1

print(sum(x*(x-1)//2 for x in d.values()))