using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

class Program
{
    private static int Solve(int N, int K, int[] a)
    {
        int sum = a.Where(n => n > 0).Sum();
        int nsum = 0;
        int psum = 0;
        for (int i = 0; i < K; ++i)
        {
            if (a[i] < 0) { nsum += a[i]; }
            if (a[i] > 0) { psum += a[i]; }
        }
        int nmax = nsum;
        int pmin = psum;
        for (int i = K; i < N; ++i)
        {
            if (a[i - K] < 0) { nsum -= a[i - K]; }
            if (a[i] < 0) { nsum += a[i]; }
            if (a[i - K] > 0) { psum -= a[i - K]; }
            if (a[i] > 0) { psum += a[i]; }
            nmax = Math.Max(nsum, nmax);
            pmin = Math.Min(psum, pmin);
        }
        return Math.Max(sum + nmax, sum - pmin);
    }
    static void Main(string[] args)
    {
        int[] values = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = values[0];
        int K = values[1];
        int[] a = new int[N];
        int n1 = 0;
        string A = Console.ReadLine();
        for (int i = 0; i < N; ++i)
        {
            int n2 = A.IndexOf(' ', n1);
            if (n2 == -1)
            {
                a[i] = int.Parse(A.Substring(n1));
            }
            else
            {
                a[i] = int.Parse(A.Substring(n1, n2 - n1));
                n1 = n2 + 1;
            }
        }
        Console.WriteLine(Solve(N, K, a));
    }
}
