n,k=list(map(int,input().split()))

a=[0]+list(map(int,input().split()))

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

from collections import defaultdict

d=defaultdict(int)

x=0

d[0]=1

for i in range(1,n+1):

  if i-k>=0:d[a[i-k]]-=1

  x+=d[a[i]]

  d[a[i]]+=1

print(x)
from collections import defaultdict

n,k=list(map(int,input().split()))

a=list(map(int,input().split()))

a[0]=(a[0]-1)%k

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

d=defaultdict(int)

ans=0

d[0]=1

for i in range(n):

  if i==k-1:d[0]-=1

  if i>=k:d[a[i-k]]-=1

  ans+=d[a[i]]

  d[a[i]]+=1

print(ans)
n, k = list(map(int, input().split()))
a = [0] + list(map(int, input().split()))
for i in range(n):
    a[i + 1] = (a[i + 1] + a[i] - 1) % k
from collections import defaultdict

d = defaultdict(int)
x = 0
d[0] = 1
for i in range(1, n + 1):
    if i - k >= 0:
        d[a[i - k]] -= 1
    x += d[a[i]]
    d[a[i]] += 1
print(x)

from collections import defaultdict

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a[0] = (a[0] - 1) % k
for i in range(n - 1):
    a[i + 1] = (a[i + 1] + a[i] - 1) % k
d = defaultdict(int)
ans = 0
d[0] = 1
for i in range(n):
    if i == k - 1:
        d[0] -= 1
    if i >= k:
        d[a[i - k]] -= 1
    ans += d[a[i]]
    d[a[i]] += 1
print(ans)

-n, k = list(map(int, input().split())) -a = [0] + list(map(int, input().split())) -for i in range(n): -    a[i + 1] = (a[i + 1] + a[i] - 1) % k +n, k = list(map(int, input().split())) +a = list(map(int, input().split())) +a[0] = (a[0] - 1) % k +for i in range(n - 1): +    a[i + 1] = (a[i + 1] + a[i] - 1) % k -x = 0 +ans = 0 -for i in range(1, n + 1): -    if i - k >= 0: +for i in range(n): +    if i == k - 1: +        d[0] -= 1 +    if i >= k: -    x += d[a[i]] +    ans += d[a[i]] -print(x) +print(ans)