N, M = map(int, input().split())
A = list(map(int, input().split()))

# 累積和

cumsum = [0]
for i in range(len(A)):
    cumsum.append(cumsum[i] + A[i])

ret = 0
for l in range(1, N+1):
    for r in range(l, N+1):
        s = cumsum[r] - cumsum[l -1]
        if s % M == 0:
            ret += 1
print(ret)
