from itertools import accumulate
from collections import Counter

n, m = map(int, input().split())
ans = sum(v * (v - 1) // 2 for v in Counter([ak % m for ak in accumulate(map(int, input().split()))] + [0]).values())
print(ans)
