n,m = map(int,input().split())
a = list(map(int,input().split()))
count = 0
for i in range(0,n):
    for j in range(i,n):
        ans = sum(a[i:j+1])
        if ans % m == 0:
            count += 1
print(count)