from collections import Counter
from itertools import accumulate
from functools import reduce

N, M = map(int, input().split())
A = [int(x) for x in input().split()]

c = Counter([0] + [x % M for x in accumulate(A)])
ans = reduce(add, [v*(v-1)//2 for v in c.values()])
print(ans)
