N, M = map(int, input().split())
A_line = list(map(lambda x: int(x)%M, input().split()))

ans = 0
for i in range(N):
    for j in range(i, N):
        if i == j:
            sum_mod = A_line[i]
        else:
            sum_mod += A_line[j]
            sum_mod %= M

        if sum_mod == 0:
            ans += 1

print(ans)
