N, M = map(int, input().split())
A = [int(i) for i in input().split()]
B = [sum(A[:i])%M for i in range(1, N + 1)]
surplus = {}
res = 0
for b in B:
    surplus[b] = surplus.get(b, -1) + 1
    if b == 0:
        res += 1

print(res + sum(surplus.values()))