n, m = map(int, input().split())
aa = [int(ak) % m for ak in input().split()]
mods = {0: 0}
ans = 0
for a in aa:
    new_mods = {}
    for mod, cnt in mods.items():
        new_mods[(mod + a) % m] = cnt
    new_mods.setdefault(a, 0)
    new_mods[a] += 1
    mods = new_mods
    ans += mods.get(0, 0)
print(ans)
