N, M = [int(i) for  i in input().split()]
A = [int(i) % M for i in input().split()]
ans = sum([1 for i in A if i == 0])
tmp = A[:-1]
for i in range(1, N):
    for j in range(N-i):
        tmp[j] = (tmp[j] + A[i+j]) % M
        if tmp[j] == 0:
            ans += 1
print(ans)