from itertools import accumulate

from collections import Counter

n, k, *a = list(map(int, open(0).read().split()))

a = [x % k - 1 for x in a]

a = [0] + [x % k for x in accumulate(a)]

d = Counter()

ans = 0

for l, r in zip([k] * min(k, n + 1) + a, a):

	d[l] -= 1

	ans += d[r]

	d[r] += 1

print(ans)

n,k,*a=list(map(int, open(0).read().split()))

b=[0]*-~n

for i in range(n):b[i+1]=(a[i]+b[i]-1)%k

d={k:0}

a=0

for l,r in zip([k]*min(k,n+1)+b,b):d[l]-=1;t=d.get(r,0);a+=t;d[r]=t+1

print(a)
from itertools import accumulate
from collections import Counter

n, k, *a = list(map(int, open(0).read().split()))
a = [x % k - 1 for x in a]
a = [0] + [x % k for x in accumulate(a)]
d = Counter()
ans = 0
for l, r in zip([k] * min(k, n + 1) + a, a):
    d[l] -= 1
    ans += d[r]
    d[r] += 1
print(ans)

n, k, *a = list(map(int, open(0).read().split()))
b = [0] * -~n
for i in range(n):
    b[i + 1] = (a[i] + b[i] - 1) % k
d = {k: 0}
a = 0
for l, r in zip([k] * min(k, n + 1) + b, b):
    d[l] -= 1
    t = d.get(r, 0)
    a += t
    d[r] = t + 1
print(a)

-from itertools import accumulate -from collections import Counter - -a = [x % k - 1 for x in a] -a = [0] + [x % k for x in accumulate(a)] -d = Counter() -ans = 0 -for l, r in zip([k] * min(k, n + 1) + a, a): +b = [0] * -~n +for i in range(n): +    b[i + 1] = (a[i] + b[i] - 1) % k +d = {k: 0} +a = 0 +for l, r in zip([k] * min(k, n + 1) + b, b): -    ans += d[r] -    d[r] += 1 -print(ans) +    t = d.get(r, 0) +    a += t +    d[r] = t + 1 +print(a)