using System;
using System.IO;
using System.Linq;

namespace At{
    class agc008 {
        static string[] splits;
        static int current = 0;

        static int nextint(){
            if(splits == null || splits.Length == current){
                splits = Console.ReadLine().Split(' ').ToArray();
            }
            
            int n = int.Parse(splits[current]);
            current++;
            return n;
        }

        static int[] ints(){
            return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        }

        static int sum_only_plus(int[] arr){
            int total_plus = 0;
            foreach(int i in arr){
                if(i > 0){
                    total_plus += i;
                }
            }
            return total_plus;
        }

        static int sum_only_minus(int[] arr){
            int total_minus = 0;
            foreach(int i in arr){
                if(i < 0){
                    total_minus += i;
                }
            }
            return total_minus;
        }
        
        static void Main(){
            int n = nextint();
            int k = nextint();

            int[] arr = ints();
            int total_plus = 0;
            int total_minus = 0;

            foreach(int i in arr){
                if(i > 0){
                    total_plus += i;
                }
                else {
                    total_minus += i;
                }
            }

            int blackout;
            int whiteout;
            
            int[] slice = arr.Skip(0).Take(k).ToArray();
            int tmpmax = total_plus + sum_only_minus(slice);

            // Console.WriteLine("Black");
            for(int i = 1; i < n - k + 1; i++){
                int[] arr_slice = arr.Skip(i).Take(k).ToArray();
                blackout = total_plus + sum_only_minus(arr_slice);
                tmpmax = Math.Max(tmpmax,blackout);
                // Console.WriteLine(i + " ~ " + (i+k-1) +" " + blackout);
            }

            // Console.WriteLine("White");
            for(int i = 0; i < n - k + 1; i++){
                int[] arr_slice = arr.Skip(i).Take(k).ToArray();
                whiteout = total_plus - sum_only_plus(arr_slice);
                tmpmax = Math.Max(tmpmax,whiteout);
                // Console.WriteLine(i + " ~ " + (i+k-1) +" " + whiteout);
            }

            Console.WriteLine(tmpmax);
        }
    }
}

