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

a=[0]+a

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

d={}

c=0

for i,b in enumerate(a):

  v=d.get(b,0)

  c+=v

  d[b]=v+1

  j=i-k+1

  if j>=0:d[a[j]]=d.get(a[j],0)-1

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

b=[0]

for t in a:b+=(t-1+b[-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)
n, k, *a = list(map(int, open(0).read().split()))
a = [0] + a
for i in range(n):
    a[i + 1] = (a[i + 1] - 1 + a[i]) % k
d = {}
c = 0
for i, b in enumerate(a):
    v = d.get(b, 0)
    c += v
    d[b] = v + 1
    j = i - k + 1
    if j >= 0:
        d[a[j]] = d.get(a[j], 0) - 1
print(c)

n, k, *a = list(map(int, open(0).read().split()))
b = [0]
for t in a:
    b += ((t - 1 + b[-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)

-a = [0] + a -for i in range(n): -    a[i + 1] = (a[i + 1] - 1 + a[i]) % k -d = {} -c = 0 -for i, b in enumerate(a): -    v = d.get(b, 0) -    c += v -    d[b] = v + 1 -    j = i - k + 1 -    if j >= 0: -        d[a[j]] = d.get(a[j], 0) - 1 -print(c) +b = [0] +for t in a: +    b += ((t - 1 + b[-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)