N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
from collections import Counter
mods = Counter()
for a in A:
    mods = Counter({(k + a) % M: v for k, v in mods.items()})
    mods[a % M] += 1
    ans += mods[0]

print(ans)
