public void solve() throws IOException {
    int n = nextInt();
    int k = nextInt();
    
    int tot = 0;
    int[] arr = new int[n];
    for (int i = 0; i < n; i++) {
      arr[i] = nextInt();
      tot += arr[i];
    }
    if (2 * k >= n) {
      System.out.println(tot);
      return;
    }
        
    int ksum = 0;
    for (int i = 0; i < k; i++) {
      ksum += arr[i];
    }
    int kmax = ksum;
    
    int cursum = 0; 
    for (int i = k; i < 2 * k; i++) {
      cursum += arr[i];
    }
    
    int maxtot = kmax + cursum;
    for (int i = k + 1; i <= n - k; i++) {
      ksum += arr[i - 1];
      ksum -= arr[i - k - 1];
      kmax = Math.max(ksum, kmax);
      
      cursum -= arr[i - 1];
      cursum += arr[i + k - 1];
      maxtot = Math.max(maxtot, cursum + kmax);
    }
    
    System.out.println(maxtot);
  }