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

ans = 0
mod = 0
mod_dic = {0: 1}
for a in A:
    mod = (mod + a) % M
    mod_dic[mod] = mod_dic.get(mod, 0) + 1

for v in mod_dic.values():
    ans += v * (v - 1) // 2

print(ans)