N, M = map(int, input().split())
A = list(map(int, input().split()))
S_mod = [0]
s = 0
for a in A:
    s += a
    S_mod.append(s % M)

count = 0
for r in range(1, N+1):
    if S_mod[r] == 0:
        count += 1
    count += S_mod[(r + 1):].count(S_mod[r])

print(count)
