output_description: Print the number of subsequences that satisfy the condition.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      A_1 A_2 \cdots A_N
attempt: N, K = map(int, input().split())
  A = list(map(int, input().split()))
  X = [0 for _ in range(N)]
  D = {0: [-1]}
  E = {0: 1}
  X[0] = (A[0] - 1) % K
  if X[0] in D:
      D[X[0]].append(0)
      E[X[0]] += 1
  else:
      D[X[0]] = [0]
      E[X[0]] = 1
  for i in range(1, N):
      X[i] = (X[i - 1] + A[i] - 1) % K
      if X[i] in D:
          D[X[i]].append(i)
          E[X[i]] += 1
      else:
          D[X[i]] = [i]
          E[X[i]] = 1
  S = 0
  for i in D:
      n = E[i]
      if n > 1:
          L = D[i][:]
          m = L[-1]
          for j in range(n - 1):
              x = L[j]
              if m - x < K:
                  S += n - 1 - j
              else:
                  l, r = j, n
                  d = (l + r) // 2
                  tmp = 2 * n
                  while tmp != 0:
                      if L[d] - x <= K - 1:
                          l = d
                          d = (l + r) // 2
                      else:
                          r = d
                          d = (l + r) // 2
                      tmp //= 2
                      print(L[j], L[d], l, d, r)
                  S += d - j
  print(S)
  
problem_description: Statement
  
  Given are a sequence of N positive integers A_1, A_2, \ldots, A_N, and a
  positive integer K.
  
  Find the number of non-empty contiguous subsequences in A such that the
  remainder when dividing the sum of its elements by K is equal to the number of
  its elements. We consider two subsequences different if they are taken from
  different positions, even if they are equal sequences.
samples: [{"input": "5 4\n    1 4 2 3 5", "output": "4\n    \n\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\n* * *"}, {"input": "8 4\n    4 2 4 2 4 2 4 2", "output": "7\n    \n\n(4,2) is counted four times, and (2,4) is counted three times.\n\n* * *"}, {"input": "10 7\n    14 15 92 65 35 89 79 32 38 46", "output": "8"}]