N, M = map(int, input().split(" "))
A_arr = list(map(int, input().split(" ")))
t = 0
for x1 in range(N):
    for x2 in range(x1,N):

        if x1 == x2:
            a = A_arr[x1]
        else:
            a = sum(A_arr[x1:x2+1])

        if a % M == 0:
            t += 1
        else:
            pass
print(t)