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

ans = 0
mod = {}
last_mod = {}
for a in A:
    mod = {}
    # print(mod, last_mod)
    m = a % M
    for key in last_mod:
        mod[(key + m) % M] = last_mod[key]
    mod[m] = mod.get(m, 0) + 1

    # print(mod, last_mod)
    ans += mod.get(0, 0)

    last_mod = mod

print(ans)