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