output_description: Print the maximum possible score.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N K
      a_1 a_2 ... a_N
attempt: import sys
  import heapq
  from operator import itemgetter
  from collections import deque, defaultdict
  from bisect import bisect_left, bisect_right
  
  input = sys.stdin.readline
  sys.setrecursionlimit(10**7)
  
  
  def sol():
      N, K = map(int, input().split())
  
      A = list(map(int, input().split()))
      sumPlus = [0] * (N + 1)
      sumA = [0] * (N + 1)
  
      for i, a in enumerate(A):
          sumA[i + 1] = sumA[i] + a
          if a > 0:
              sumPlus[i + 1] = sumPlus[i] + a
          else:
              sumPlus[i + 1] = sumPlus[i]
  
      ans = 0
      for left in range(N - K + 1):  # []left - left + K) を捨てる or 加える
          leftSum = sumPlus[left]
          rightSum = sumPlus[N] - sumPlus[left + K]
          midSum = sumA[left + K] - sumA[left]
  
          if midSum > 0:
              ans = max(ans, leftSum + rightSum + midSum)
          else:
              ans = max(ans, leftSum + rightSum)
  
      print(ans)
  
  
  sol()
  
problem_description: Statement
  
  There are N squares aligned in a row. The i-th square from the left contains
  an integer a_i.
  
  Initially, all the squares are white. Snuke will perform the following
  operation some number of times:
  
    * Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here, the colors of the squares are overwritten.
  
  After Snuke finishes performing the operation, the score will be calculated as
  the sum of the integers contained in the black squares. Find the maximum
  possible score.
samples: [{"input": "5 3\n    -10 10 -10 10 -10", "output": "10\n    \n\nPaint the following squares black: the second, third and fourth squares from\nthe left.\n\n* * *"}, {"input": "4 2\n    10 -10 -10 10", "output": "20\n    \n\nOne possible way to obtain the maximum score is as follows:\n\n  * Paint the following squares black: the first and second squares from the left.\n  * Paint the following squares black: the third and fourth squares from the left.\n  * Paint the following squares white: the second and third squares from the left.\n\n* * *"}, {"input": "1 1\n    -10", "output": "0\n    \n\n* * *"}, {"input": "10 5\n    5 -4 -5 -8 -4 7 2 -4 0 7", "output": "17"}]