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()))