using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int K = NextInt();
        int[] ai = LineInt();

        //K個の連続部分1個を除き全部好きに塗ることが出来る
        SegmentTree<long> ST = new SegmentTree<long>(N, 0, (x, y) => (x + y), (x, y) => (x + y));
        for (int i = 0; i < N; i++) if (ai[i] > 0) ST.Add(i, ai[i]);

        // K < N なので累積和
        long sum = 0;
        long[] nyan = new long[N + 1];
        for (int i = 1; i <= N; i++) nyan[i] += nyan[i - 1] + ai[i - 1];

        long ans = 0;
        for (int i = 0; i <= N - K; i++)
        {
            //区間全部取るか全部捨てるか
            long white = ST.Query(0, i) + ST.Query(i + K, N);
            long black = white + (nyan[i + K] - nyan[i]);
            ans = Math.Max(ans, Math.Max(black, white));
        }
        Console.WriteLine(ans);
    }

    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class SegmentTree<T>
{
    private List<T> table = new List<T>();
    private static int size = 1;
    private static int high = 1;
    private static T lim;
    private static Func<T, T, T> func;
    private static Func<T, T, T> upd_func;
    public SegmentTree(int n, T m, Func<T, T, T> f, Func<T, T, T> upd_f)
    {
        while (size < n) size *= 2;
        high = (int)Math.Log(size, 2);
        for (int i = 0; i < 2 * size - 1; i++) table.Add(m);
        lim = m;
        func = f;
        upd_func = upd_f;
    }
    public void Add(int x, T v)
    {
        x += size - 1;
        table[x] = v;
        while (x != 0)
        {
            x = (x % 2 == 0 ? x / 2 - 1 : x / 2);
            table[x] = upd_func(table[x * 2 + 1], table[x * 2 + 2]);
        }
    }
    public T Query(int a, int b, int x = 0, int l = 0, int r = 0)
    {
        if (r <= l) r = size;
        if (r <= a || b <= l) return lim;
        if (a <= l && r <= b) return table[x];
        T left = Query(a, b, x * 2 + 1, l, (r + l) / 2);
        T right = Query(a, b, x * 2 + 2, (r + l) / 2, r);
        return func(left, right);
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 32092