N, M = map(int, raw_input().split())
A = map(int, raw_input().split())

AX = [0]
s = 0
for a in A:
    s += a
    AX.append(s)

result = []
for i in range(1, N+1):
    for j in range(1, N+1):
        if i <= j:
            if (AX[j] - AX[i-1]) % M == 0:
                result.append((i,j,AX[j] - AX[i-1]))
print(len(result))
