#define _CRT_SECURE_NO_DEPRECATE
#define _SECURE_SCL 0

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <iostream>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <cctype>
#include <sstream>
#include <cassert>
#include <bitset>
#include <memory.h>
#include <complex>

using namespace std;

#pragma comment(linker, "/STACK:200000000")

typedef long long int64;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define fore(i, a, n) for(int i = (int)(a); i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) (int(a.size()) - 1)
#define all(a) a.begin(), a.end()

const double EPS = 1E-9;
const int INF = 1000000000;
const int64 INF64 = (int64) 1E18;
const double PI = 3.1415926535897932384626433832795;

int n, len, k;
int64 a[110000];
int64 sq;
set<pair<int64, int> > q1, q2;

void add(int id) {
    if (a[id] < 0) {
        q1.insert(mp(-2 * a[id], id));
        sq += -2 * a[id];
        if ((int)q1.size() > k) {
            sq -= q1.begin()->fs;
            q2.insert(*q1.begin());
            q1.erase(q1.begin());
        }
    }
}

void del(int id) {
    if (a[id] < 0) {
        if (q1.count(mp(-2 * a[id], id))) {
            sq -= -2 * a[id];
            q1.erase(mp(-2 * a[id], id));
        }
        else
            q2.erase(mp(-2 * a[id], id));

        if ((int)q1.size() < k && !q2.empty()) {
            sq += q2.rbegin()->fs;
            q1.insert(*q2.rbegin());
            q2.erase(--q2.end());
        }
    }
}

int64 solve() {
    sq = 0;
    q1.clear();
    q2.clear();
    int64 sum = 0;
    forn(i, len) {
        add(i);
        sum += a[i];
    }

    int64 res = sum + sq;
    for (int i = len; i < n; i++) {
        del(i - len);
        add(i);
        sum -= a[i - len];
        sum += a[i];

        res = max(res, sum + sq);
    }

    return res;
}

int main() {
#ifdef RADs_project
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
#endif

    cin >> n >> len;
    forn(i, n)
        scanf("%I64d", &a[i]);
    cin >> k;
    k = min(k, len);

    int64 res = solve();
    forn(i, n)
        a[i] *= -1;
    res = max(res, solve());

    cout << res << endl;

    return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<map>

using namespace std;

long long ans,sum;
int n,len,k,cnt,l,r;
set<pair<int,int>>t,dt;
set<pair<int,int>>::iterator it;
vector<int>a;

int main()
{
    scanf("%d%d",&n,&len);
    for(int i=0;i<n;++i)
    {
        int num;
        scanf("%d",&num);
        a.push_back(num);
    }
    scanf("%d",&k);
    r=-1;
    for(;r<n;)
    {
        if(r-l+1<len)
        {
            ++r;
            if(r<n)
            {
                if(a[r]>0)
                {
                    sum+=a[r];
                }
                else
                {
                    if(t.size()<k)
                    {
                        t.insert(make_pair(-a[r],r));
                        sum-=a[r];
                    }
                    else
                    {
                        it=t.begin();
                        if(it!=t.end()&&(*it).first<-a[r])
                        {
                            sum-=2*(*it).first;
                            dt.insert(*it);
                            t.erase(it);
                            sum-=a[r];
                            t.insert(make_pair(-a[r],r));
                        }
                        else
                        {
                            dt.insert(make_pair(a[r],r));
                            sum+=a[r];
                        }
                    }
                }
            }
        }
        else
        {
            ans=max(ans,sum);
            if(a[l]<=0)
            {
                int cntb=t.size();
                t.erase(make_pair(-a[l],l));
                if(cntb>t.size())
                {
                    sum+=a[l];
                    it=dt.begin();
                    if(it!=dt.end())
                    {
                        t.insert(*it);
                        sum-=2*(*it).first;
                        dt.erase(it);
                    }
                }
                else
                {
                    sum-=a[l];
                    dt.erase(make_pair(a[l],r));
                }
            }else
                sum-=a[l];
            ++l;
        }
    }
    for(int i=0;i<n;++i)
        a[i]*=-1;
    l=0;
    cnt=0;
    t.clear();
    dt.clear();
    sum=0;
    r=-1;
    for(;r<n;)
    {
        if(r-l+1<len)
        {
            ++r;
            if(r<n)
            {
                if(a[r]>0)
                {
                    sum+=a[r];
                }
                else
                {
                    if(t.size()<k)
                    {
                        t.insert(make_pair(-a[r],r));
                        sum-=a[r];
                    }
                    else
                    {
                        it=t.begin();
                        if(it!=t.end()&&(*it).first<-a[r])
                        {
                            sum-=2*(*it).first;
                            dt.insert(*it);
                            t.erase(it);
                            sum-=a[r];
                            t.insert(make_pair(-a[r],r));
                        }
                        else
                        {
                            dt.insert(make_pair(a[r],r));
                            sum+=a[r];
                        }
                    }
                }
            }
        }
        else
        {
            ans=max(ans,sum);
            if(a[l]<=0)
            {
                int cntb=t.size();
                t.erase(make_pair(-a[l],l));
                if(cntb>t.size())
                {
                    sum+=a[l];
                    it=dt.begin();
                    if(it!=dt.end())
                    {
                        t.insert(*it);
                        sum-=2*(*it).first;
                        dt.erase(it);
                    }
                }
                else
                {
                    sum-=a[l];
                    dt.erase(make_pair(a[l],l));
                }
            }
            else
                sum-=a[l];
            ++l;
        }
    }
    printf("%I64d",ans);
    return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<map>

using namespace std;

long long ans,sum;
int n,len,k,cnt,l,r;
set<pair<int,int>>t,dt;
set<pair<int,int>>::iterator it;
vector<int>a;

int main()
{
    scanf("%d%d",&n,&len);
    for(int i=0;i<n;++i)
    {
        int num;
        scanf("%d",&num);
        a.push_back(num);
    }
    scanf("%d",&k);
    r=-1;
    for(;r<n;)
    {
        if(r-l+1<len)
        {
            ++r;
            if(r<n)
            {
                if(a[r]>0)
                {
                    sum+=a[r];
                }
                else
                {
                    if(t.size()<k)
                    {
                        t.insert(make_pair(-a[r],r));
                        sum-=a[r];
                    }
                    else
                    {
                        it=t.begin();
                        if(it!=t.end()&&(*it).first<-a[r])
                        {
                            sum-=2*(*it).first;
                            dt.insert(*it);
                            t.erase(it);
                            sum-=a[r];
                            t.insert(make_pair(-a[r],r));
                        }
                        else
                        {
                            dt.insert(make_pair(a[r],r));
                            sum+=a[r];
                        }
                    }
                }
            }
        }
        else
        {
            ans=max(ans,sum);
            if(a[l]<=0)
            {
                int cntb=t.size();
                t.erase(make_pair(-a[l],l));
                if(cntb>t.size())
                {
                    sum+=a[l];
                    it=dt.begin();
                    if(it!=dt.end())
                    {
                        t.insert(make_pair(-(*it).first,(*it).second));
                        sum-=2*(*it).first;
                        dt.erase(it);
                    }
                }
                else
                {
                    sum-=a[l];
                    dt.erase(make_pair(a[l],l));
                }
            }else
                sum-=a[l];
            ++l;
        }
    }
    for(int i=0;i<n;++i)
        a[i]*=-1;
    l=0;
    cnt=0;
    t.clear();
    dt.clear();
    sum=0;
    r=-1;
    for(;r<n;)
    {
        if(r-l+1<len)
        {
            ++r;
            if(r<n)
            {
                if(a[r]>0)
                {
                    sum+=a[r];
                }
                else
                {
                    if(t.size()<k)
                    {
                        t.insert(make_pair(-a[r],r));
                        sum-=a[r];
                    }
                    else
                    {
                        it=t.begin();
                        if(it!=t.end()&&(*it).first<-a[r])
                        {
                            sum-=2*(*it).first;
                            dt.insert(*it);
                            t.erase(it);
                            sum-=a[r];
                            t.insert(make_pair(-a[r],r));
                        }
                        else
                        {
                            dt.insert(make_pair(a[r],r));
                            sum+=a[r];
                        }
                    }
                }
            }
        }
        else
        {
            ans=max(ans,sum);
            if(a[l]<=0)
            {
                int cntb=t.size();
                t.erase(make_pair(-a[l],l));
                if(cntb>t.size())
                {
                    sum+=a[l];
                    it=dt.begin();
                    if(it!=dt.end())
                    {
                        t.insert(make_pair(-(*it).first,(*it).second));
                        sum-=2*(*it).first;
                        dt.erase(it);
                    }
                }
                else
                {
                    sum-=a[l];
                    dt.erase(make_pair(a[l],l));
                }
            }else
                sum-=a[l];
            ++l;
        }
    }
    printf("%I64d",ans);
    return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<map>

using namespace std;

long long ans,sum;
int n,len,k,cnt,l,r;
set<pair<int,int>>t,dt;
set<pair<int,int>>::iterator it;
vector<int>a;

int main()
{
    scanf("%d%d",&n,&len);
    for(int i=0;i<n;++i)
    {
        int num;
        scanf("%d",&num);
        a.push_back(num);
    }
    scanf("%d",&k);
    r=-1;
    for(;r<n;)
    {
        if(r-l+1<len)
        {
            ++r;
            if(r<n)
            {
                if(a[r]>0)
                {
                    sum+=a[r];
                }
                else
                {
                    if(t.size()<k)
                    {
                        t.insert(make_pair(-a[r],r));
                        sum-=a[r];
                    }
                    else
                    {
                        it=t.begin();
                        if(it!=t.end()&&(*it).first<-a[r])
                        {
                            sum-=2*(*it).first;
                            dt.insert(*it);
                            t.erase(it);
                            sum-=a[r];
                            t.insert(make_pair(-a[r],r));
                        }
                        else
                        {
                            dt.insert(make_pair(a[r],r));
                            sum+=a[r];
                        }
                    }
                }
            }
        }
        else
        {
            ans=max(ans,sum);
            if(a[l]<=0)
            {
                int cntb=t.size();
                t.erase(make_pair(-a[l],l));
                if(cntb>t.size())
                {
                    sum+=a[l];
                    it=dt.begin();
                    if(it!=dt.end())
                    {
                        t.insert(*it);
                        sum-=2*(*it).first;
                        dt.erase(it);
                    }
                }
                else
                {
                    sum-=a[l];
                    dt.erase(make_pair(a[l],r));
                }
            }
            ++l;
        }
    }
    for(int i=0;i<n;++i)
        a[i]*=-1;
    l=0;
    cnt=0;
    t.clear();
    dt.clear();
    sum=0;
    r=-1;
    for(;r<n;)
    {
        if(r-l+1<len)
        {
            ++r;
            if(r<n)
            {
                if(a[r]>0)
                {
                    sum+=a[r];
                }
                else
                {
                    if(t.size()<k)
                    {
                        t.insert(make_pair(-a[r],r));
                        sum-=a[r];
                    }
                    else
                    {
                        it=t.begin();
                        if(it!=t.end()&&(*it).first<-a[r])
                        {
                            sum-=2*(*it).first;
                            dt.insert(*it);
                            t.erase(it);
                            sum-=a[r];
                            t.insert(make_pair(-a[r],r));
                        }
                        else
                        {
                            dt.insert(make_pair(a[r],r));
                            sum+=a[r];
                        }
                    }
                }
            }
        }
        else
        {
            ans=max(ans,sum);
            if(a[l]<=0)
            {
                int cntb=t.size();
                t.erase(make_pair(-a[l],l));
                if(cntb>t.size())
                {
                    sum+=a[l];
                    it=dt.begin();
                    if(it!=dt.end())
                    {
                        t.insert(*it);
                        sum-=2*(*it).first;
                        dt.erase(it);
                    }
                }
                else
                {
                    sum-=a[l];
                    dt.erase(make_pair(a[l],l));
                }
            }
            ++l;
        }
    }
    printf("%I64d",ans);
    return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<map>

using namespace std;

long long ans;
int l,r,n,len,k,w[100000];
set<pair<int,int>> ms;
set<pair<int,int>>::iterator it;
vector<int>a;

int main()
{
    scanf("%d%d",&n,&len);
    for(int i=0;i<n;++i)
    {
        int num;
        scanf("%d",&num);a.push_back(num);
    }
    scanf("%d",&k);

    r=-1;
    l=0;
    long long sum=0;
    int cnt=0;
    for(;r<n;)
    {
        if(r-l+1<len)
        {
            ++r;
            if(r<n)
            {
                if(a[r]>0)
                    sum+=a[r];
                else
                {
                    if(cnt<k)
                    {
                        ++cnt;
                        sum-=a[r];
                        ms.insert(make_pair(-a[r],r));
                    }
                    else
                    {
                        it=ms.begin();
                        if(it!=ms.end()&&(*it).first<-a[r])
                        {
                            sum-=(a[r]+(*it).first);
                            ms.erase(it);
                            ms.insert(make_pair(-a[r],r));
                        }
                        else
                            sum+=a[r];
                    }
                }
            }
        }
        else
        {
            ans=max(ans,sum);
            if(a[l]<0)
            {
                int cntb=cnt;
                ms.erase(make_pair(-a[l],l));
                cnt=ms.size();
                if(cntb>cnt)
                    sum+=a[l];
                else
                    sum-=a[l];
            }
            else
                sum-=a[l];
            ++l;
        }
    }
    printf("%I64d",ans);
    return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<map>

using namespace std;

long long ans,sum;
int n,len,k,cnt,l,r;
set<pair<int,int>>t,dt;
set<pair<int,int>>::iterator it;
vector<int>a;

int main()
{
    scanf("%d%d",&n,&len);
    for(int i=0;i<n;++i)
    {
        int num;
        scanf("%d",&num);
        a.push_back(num);
    }
    scanf("%d",&k);
    r=-1;
    for(;r<n;)
    {
        if(r-l+1<len)
        {
            ++r;
            if(r<n)
            {
                if(a[r]>0)
                {
                    sum+=a[r];
                }
                else
                {
                    if(t.size()<k)
                    {
                        t.insert(make_pair(-a[r],r));
                        sum-=a[r];
                    }
                    else
                    {
                        it=t.begin();
                        if(it!=t.end()&&(*it).first<-a[r])
                        {
                            sum-=2*(*it).first;
                            dt.insert(make_pair(-(*it).first,(*it).second));
                            t.erase(it);
                            sum-=a[r];
                            t.insert(make_pair(-a[r],r));
                        }
                        else
                        {
                            dt.insert(make_pair(a[r],r));
                            sum+=a[r];
                        }
                    }
                }
            }
        }
        else
        {
            ans=max(ans,sum);
            if(a[l]<=0)
            {
                int cntb=t.size();
                t.erase(make_pair(-a[l],l));
                if(cntb>t.size())
                {
                    sum+=a[l];
                    it=dt.begin();
                    if(it!=dt.end())
                    {
                        t.insert(make_pair(-(*it).first,(*it).second));
                        sum-=2*(*it).first;
                        dt.erase(it);
                    }
                }
                else
                {
                    sum-=a[l];
                    dt.erase(make_pair(a[l],l));
                }
            }else
                sum-=a[l];
            ++l;
        }
    }
    for(int i=0;i<n;++i)
        a[i]*=-1;
    l=0;
    cnt=0;
    t.clear();
    dt.clear();
    sum=0;
    r=-1;
    for(;r<n;)
    {
        if(r-l+1<len)
        {
            ++r;
            if(r<n)
            {
                if(a[r]>0)
                {
                    sum+=a[r];
                }
                else
                {
                    if(t.size()<k)
                    {
                        t.insert(make_pair(-a[r],r));
                        sum-=a[r];
                    }
                    else
                    {
                        it=t.begin();
                        if(it!=t.end()&&(*it).first<-a[r])
                        {
                            sum-=2*(*it).first;
                            dt.insert(make_pair(-(*it).first,(*it).second));
                            t.erase(it);
                            sum-=a[r];
                            t.insert(make_pair(-a[r],r));
                        }
                        else
                        {
                            dt.insert(make_pair(a[r],r));
                            sum+=a[r];
                        }
                    }
                }
            }
        }
        else
        {
            ans=max(ans,sum);
            if(a[l]<=0)
            {
                int cntb=t.size();
                t.erase(make_pair(-a[l],l));
                if(cntb>t.size())
                {
                    sum+=a[l];
                    it=dt.begin();
                    if(it!=dt.end())
                    {
                        t.insert(make_pair(-(*it).first,(*it).second));
                        sum-=2*(*it).first;
                        dt.erase(it);
                    }
                }
                else
                {
                    sum-=a[l];
                    dt.erase(make_pair(a[l],l));
                }
            }else
                sum-=a[l];
            ++l;
        }
    }
    printf("%I64d",ans);
    return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<map>

using namespace std;

long long ans;
int l,r,n,len,k,w[100000];
set<pair<int,int>> ms,ms2;
set<pair<int,int>>::iterator it;
vector<int>a;

int main()
{
    scanf("%d%d",&n,&len);
    for(int i=0;i<n;++i)
    {
        int num;
        scanf("%d",&num);a.push_back(num);
    }
    scanf("%d",&k);
    r=-1;
    l=0;
    long long sum=0;
    int cnt=0;
    for(;r<n;)
    {
        if(r-l+1<len)
        {
            ++r;
            if(r<n)
            {
                if(a[r]>0)
                    sum+=a[r];
                else
                {
                    if(cnt<k)
                    {
                        ++cnt;
                        sum-=a[r];
                        ms.insert(make_pair(-a[r],r));
                    }
                    else
                    {
                        it=ms.begin();
                        if(it!=ms.end()&&(*it).first<-a[r])
                        {
                            sum-=(a[r]+(*it).first);
                            ms.erase(it);
                            ms.insert(make_pair(-a[r],r));
                        }
                        else
                            sum+=a[r];
                    }
                }
            }
        }
        else
        {
            ans=max(ans,sum);
            if(a[l]<0)
            {
                int cntb=cnt;
                ms.erase(make_pair(-a[l],l));
                cnt=ms.size();
                if(cntb>cnt)
                    sum+=a[l];
                else
                    sum-=a[l];
            }
            else
                sum-=a[l];
            ++l;
        }
    }
    int r2=-1;
    int l2=0;
    long long sum2=0;
    int cnt2=0;
    for(;r2<n;)
    {
        if(r2-l2+1<len)
        {
            ++r2;
            if(r2<n)
            {
                if(a[r2]<0)
                    sum2+=a[r2];
                else
                {
                    if(cnt2<k)
                    {
                        ++cnt2;
                        sum2-=a[r2];
                        ms2.insert(make_pair(a[r2],r2));
                    }
                    else
                    {
                        it=ms2.begin();
                        if(it!=ms2.end()&&(*it).first<a[r2])
                        {
                            sum2-=(a[r2]-(*it).first);
                            ms2.erase(it);
                            ms2.insert(make_pair(a[r2],r2));
                        }
                        else
                            sum2+=a[r2];
                    }
                }
            }
        }
        else
        {
            ans=max(ans,-sum2);
            if(a[l2]>0)
            {
                int cntb=cnt2;
                ms2.erase(make_pair(a[l2],l2));
                cnt2=ms2.size();
                if(cntb>cnt2)
                    sum2+=a[l2];
                else
                    sum2-=a[l2];
            }
            else
                sum2-=a[l2];
            ++l2;
        }
    }
    printf("%I64d",ans);
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF 10000000000000000
#define maxn 100010
struct node{
	int l,r,v;
	long long val;
	int mid(){ return (l+r)>>1; }
}tree1[maxn*4],tree2[maxn*4];
int g[maxn],n,m,k,tot;
long long a[maxn],b[maxn];
inline long long ab(long long a){ if(a>0) return a; return -a; }
void crt1(int l,int r,int id)
{
	tree1[id].l=l; tree1[id].r=r; tree1[id].v=tree1[id].val=0;
	if(l==r) return; int mid=tree1[id].mid();
	crt1(l,mid,id<<1); crt1(mid+1,r,(id<<1)|1);
}
void upd1(int l,int v,int id)
{
	if(tree1[id].l==tree1[id].r)
	{
		tree1[id].v+=v;
		tree1[id].val=tree1[id].v*b[tree1[id].l];
		return;
	}
	int mid=tree1[id].mid();
	if(l<=mid) upd1(l,v,id<<1);
	else upd1(l,v,(id<<1)|1);
	tree1[id].v=tree1[id<<1].v+tree1[(id<<1)|1].v;
	tree1[id].val=tree1[id<<1].val+tree1[(id<<1)|1].val;
}
int getk1(int k,int id)
{
	if(tree1[id].l==tree1[id].r)
		return tree1[id].l;
	int mid=tree1[id].mid();
	if(tree1[(id<<1)|1].v>=k) getk1(k,(id<<1)|1);
	else getk1(k-tree1[(id<<1)|1].v,id<<1);
}
long long query1(int l,int r,int id)
{
	if(tree1[id].l>=l&&tree1[id].r<=r)
	{
		return tree1[id].val;
	}
	int mid=tree1[id].mid();
	if(r<=mid) return query1(l,r,id<<1);
	else if(l>mid) return query1(l,r,(id<<1)|1);
	else return query1(l,mid,id<<1)+query1(mid+1,r,(id<<1)|1);
}
void crt2(int l,int r,int id)
{
	tree2[id].l=l; tree2[id].r=r; tree2[id].v=tree2[id].val=0;
	if(l==r) return; int mid=tree2[id].mid();
	crt2(l,mid,id<<1); crt2(mid+1,r,(id<<1)|1);
}
void upd2(int l,int v,int id)
{
	if(tree2[id].l==tree2[id].r)
	{
		tree2[id].v+=v;
		tree2[id].val=tree2[id].v*b[tree2[id].l];
		return;
	}
	int mid=tree2[id].mid();
	if(l<=mid) upd2(l,v,id<<1);
	else upd2(l,v,(id<<1)|1);
	tree2[id].v=tree2[id<<1].v+tree2[(id<<1)|1].v;
	tree2[id].val=tree2[id<<1].val+tree2[(id<<1)|1].val;
}
int getk2(int k,int id)
{
	if(tree2[id].l==tree2[id].r)
		return tree2[id].l;
	int mid=tree2[id].mid();
	if(tree2[id<<1].v>=k) getk2(k,id<<1);
	else getk2(k-tree2[id<<1].v,(id<<1)|1);
}
long long query2(int l,int r,int id)
{
	if(tree2[id].l>=l&&tree2[id].r<=r)
	{
		return tree2[id].val;
	}
	int mid=tree2[id].mid();
	if(r<=mid) return query2(l,r,id<<1);
	else if(l>mid) return query2(l,r,(id<<1)|1);
	else return query2(l,mid,id<<1)+query2(mid+1,r,(id<<1)|1);
}

int bin(long long key)
{
	int l=1,r=tot,mid;
	while(l<r)
	{
		int mid=(l+r)>>1;
		if(b[mid]==key) return mid;
		else if(b[mid]>key) r=mid;
		else l=mid+1;
	}
}
long long sum[maxn];
int main()
{
	int i,j,l,r;
	while(scanf("%d%d",&n,&m)!=EOF)
	{
		sum[0]=0;
		for(i=1;i<=n;i++)
			scanf("%I64d",&a[i]),b[i]=a[i],sum[i]=sum[i-1]+a[i];
		scanf("%d",&k);
		sort(b+1,b+n+1); tot=2;
		for(i=2;i<=n;i++)
			if(b[i]!=b[i-1])
				b[tot++]=b[i];
		crt1(1,tot-1,1); crt2(1,tot-1,1);
		for(i=1;i<=m;i++)
		{
			if(a[i]>0)
				upd1(bin(a[i]),1,1);
			else
				upd2(bin(a[i]),1,1);
		}
		long long ans=-INF;
		if(k>m) k=m; long long tmp=sum[m]-sum[0];
		int ll=getk1(k,1); long long tmp1=query1(ll,tot-1,1);
		int rr=getk2(k,1); long long tmp2=query2(1,rr,1);
		ans=max(ans,max(ab(tmp-tmp1-tmp1),ab(tmp-tmp2-tmp2)));
		for(;i<=n;i++)
		{
			if(a[i-m]>0)
				upd1(bin(a[i-m]),-1,1);
			else upd2(bin(a[i-m]),-1,1);
			if(a[i]>0) upd1(bin(a[i]),1,1);
			else upd2(bin(a[i]),1,1);
			tmp=sum[i]-sum[i-m];
			ll=getk1(k,1); tmp1=query1(ll,tot-1,1);
			rr=getk2(k,1); tmp2=query2(1,rr,1);
			ans=max(ans,max(ab(tmp-tmp1-tmp1),ab(tmp-tmp2-tmp2)));
		}
		printf("%I64d\n",ans);
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF 10000000000000000
#define maxn 100010
struct node{
    int l,r;
    long long v,val;
    int mid(){ return (l+r)>>1; }
}tree1[maxn*4],tree2[maxn*4];
int g[maxn],n,m,k,tot;
long long a[maxn],b[maxn],v,u;
inline long long ab(long long a){ if(a>0) return a; return -a; }
void crt1(int l,int r,int id)
{
    tree1[id].l=l; tree1[id].r=r; tree1[id].v=tree1[id].val=0;
    if(l==r) return; int mid=tree1[id].mid();
    crt1(l,mid,id<<1); crt1(mid+1,r,(id<<1)|1);
}
void upd1(int l,int v,int id)
{
    if(tree1[id].l==tree1[id].r)
    {
        tree1[id].v+=v;
        tree1[id].val=tree1[id].v*b[tree1[id].l];
        return;
    }
    int mid=tree1[id].mid();
    if(l<=mid) upd1(l,v,id<<1);
    else upd1(l,v,(id<<1)|1);
    tree1[id].v=tree1[id<<1].v+tree1[(id<<1)|1].v;
    tree1[id].val=tree1[id<<1].val+tree1[(id<<1)|1].val;
}
int getk1(int k,int id)
{
    if(tree1[id].l==tree1[id].r)
    {
        u=k*b[tree1[id].l];
        return tree1[id].l;
    }
    int mid=tree1[id].mid();
    if(tree1[(id<<1)|1].v>=k) getk1(k,(id<<1)|1);
    else getk1(k-tree1[(id<<1)|1].v,id<<1);
}
long long query1(int l,int r,int id)
{
    if(tree1[id].l>=l&&tree1[id].r<=r)
    {
        return tree1[id].val;
    }
    int mid=tree1[id].mid();
    if(r<=mid) return query1(l,r,id<<1);
    else if(l>mid) return query1(l,r,(id<<1)|1);
    else return query1(l,mid,id<<1)+query1(mid+1,r,(id<<1)|1);
}
void crt2(int l,int r,int id)
{
    tree2[id].l=l; tree2[id].r=r; tree2[id].v=tree2[id].val=0;
    if(l==r) return; int mid=tree2[id].mid();
    crt2(l,mid,id<<1); crt2(mid+1,r,(id<<1)|1);
}
void upd2(int l,int v,int id)
{
    if(tree2[id].l==tree2[id].r)
    {
        tree2[id].v+=v;
        tree2[id].val=tree2[id].v*b[tree2[id].l];
        return;
    }
    int mid=tree2[id].mid();
    if(l<=mid) upd2(l,v,id<<1);
    else upd2(l,v,(id<<1)|1);
    tree2[id].v=tree2[id<<1].v+tree2[(id<<1)|1].v;
    tree2[id].val=tree2[id<<1].val+tree2[(id<<1)|1].val;
}
int getk2(int k,int id)
{
    if(tree2[id].l==tree2[id].r)
    {
        v=k*b[tree2[id].l];
        return tree2[id].l;
    }
    int mid=tree2[id].mid();
    if(tree2[id<<1].v>=k) getk2(k,id<<1);
    else getk2(k-tree2[id<<1].v,(id<<1)|1);
}
long long query2(int l,int r,int id)
{
    if(tree2[id].l>=l&&tree2[id].r<=r)
    {
        return tree2[id].val;
    }
    int mid=tree2[id].mid();
    if(r<=mid) return query2(l,r,id<<1);
    else if(l>mid) return query2(l,r,(id<<1)|1);
    else return query2(l,mid,id<<1)+query2(mid+1,r,(id<<1)|1);
}

int bin(long long key)
{
    int l=1,r=tot,mid;
    while(l<r)
    {
        int mid=(l+r)>>1;
        if(b[mid]==key) return mid;
        else if(b[mid]>key) r=mid;
        else l=mid+1;
    }
}
long long sum[maxn];
int main()
{
    int i,j,l,r,ll,rr;
    long long tmp,tmp1,tmp2;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        sum[0]=0;
        for(i=1;i<=n;i++)
            scanf("%I64d",&a[i]),b[i]=a[i],sum[i]=sum[i-1]+a[i];
        scanf("%d",&k);
        sort(b+1,b+n+1); tot=2;
        for(i=2;i<=n;i++)
            if(b[i]!=b[i-1])
                b[tot++]=b[i];
        crt1(1,tot-1,1); crt2(1,tot-1,1);
        for(i=1;i<=m;i++)
        {
            if(a[i]>0)
                upd1(bin(a[i]),1,1);
            else
                upd2(bin(a[i]),1,1);
        }
        long long ans=-INF;
        if(k>m) k=m; long long tmp=sum[m]-sum[0];
        if(k==0) ans=max(ans,ab(tmp));
        else
        {
            if(tree1[1].v>=k)
            {
                ll=getk1(k,1);
                if(ll+1<=tot-1)
                    tmp1=query1(ll+1,tot-1,1);
                else tmp1=0;
                tmp1+=u;
            }
            else tmp1=tree1[1].val;
            if(tree2[1].v>=k)
            {
                rr=getk2(k,1);
                if(rr-1>=1)
                    tmp2=query2(1,rr-1,1);
                else tmp2=0;
                tmp2+=v;
            }
            else tmp2=tree2[1].val;
            ans=max(ans,max(ab(tmp-tmp1-tmp1),ab(tmp-tmp2-tmp2)));
        }
        for(;i<=n;i++)
        {
            if(a[i-m]>0)
                upd1(bin(a[i-m]),-1,1);
            else upd2(bin(a[i-m]),-1,1);
            if(a[i]>0) upd1(bin(a[i]),1,1);
            else upd2(bin(a[i]),1,1);
            tmp=sum[i]-sum[i-m];
            if(k==0) ans=max(ans,ab(tmp));
            else
            {
                if(tree1[1].v>=k)
                {
                    ll=getk1(k,1);
                    if(ll+1<=tot-1)
                        tmp1=query1(ll+1,tot-1,1);
                    else tmp1=0;
                    tmp1+=u;
                }
                else tmp1=tree1[1].val;
                if(tree2[1].v>=k)
                {
                    rr=getk2(k,1);
                    if(rr-1>=1)
                        tmp2=query2(1,rr-1,1);
                    else tmp2=0;
                    tmp2+=v;
                }
                else tmp2=tree2[1].val;
                ans=max(ans,max(ab(tmp-tmp1-tmp1),ab(tmp-tmp2-tmp2)));
            /*  ll=getk1(k,1);
                if(ll+1<=tot-1)
                    tmp1=query1(ll+1,tot-1,1);
                else tmp1=0;
                tmp1+=u;
                rr=getk2(k,1);
                if(rr-1>=1)
                    tmp2=query2(1,rr-1,1);
                else tmp2=0;
                tmp2+=v;
                ans=max(ans,max(ab(tmp-tmp1-tmp1),ab(tmp-tmp2-tmp2)));
                */
            }
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF 10000000000000000
#define maxn 100010
struct node{
    int l,r,v;
    long long val;
    int mid(){ return (l+r)>>1; }
}tree1[maxn*4],tree2[maxn*4];
int g[maxn],n,m,k,tot;
long long a[maxn],b[maxn];
inline long long ab(long long a){ if(a>0) return a; return -a; }
void crt1(int l,int r,int id)
{
    tree1[id].l=l; tree1[id].r=r; tree1[id].v=tree1[id].val=0;
    if(l==r) return; int mid=tree1[id].mid();
    crt1(l,mid,id<<1); crt1(mid+1,r,(id<<1)|1);
}
void upd1(int l,int v,int id)
{
    if(tree1[id].l==tree1[id].r)
    {
        tree1[id].v+=v;
        tree1[id].val=tree1[id].v*b[tree1[id].l];
        return;
    }
    int mid=tree1[id].mid();
    if(l<=mid) upd1(l,v,id<<1);
    else upd1(l,v,(id<<1)|1);
    tree1[id].v=tree1[id<<1].v+tree1[(id<<1)|1].v;
    tree1[id].val=tree1[id<<1].val+tree1[(id<<1)|1].val;
}
int getk1(int k,int id)
{
    if(tree1[id].l==tree1[id].r)
        return tree1[id].l;
    int mid=tree1[id].mid();
    if(tree1[(id<<1)|1].v>=k) getk1(k,(id<<1)|1);
    else getk1(k-tree1[(id<<1)|1].v,id<<1);
}
long long query1(int l,int r,int id)
{
    if(tree1[id].l>=l&&tree1[id].r<=r)
    {
        return tree1[id].val;
    }
    int mid=tree1[id].mid();
    if(r<=mid) return query1(l,r,id<<1);
    else if(l>mid) return query1(l,r,(id<<1)|1);
    else return query1(l,mid,id<<1)+query1(mid+1,r,(id<<1)|1);
}
void crt2(int l,int r,int id)
{
    tree2[id].l=l; tree2[id].r=r; tree2[id].v=tree2[id].val=0;
    if(l==r) return; int mid=tree2[id].mid();
    crt2(l,mid,id<<1); crt2(mid+1,r,(id<<1)|1);
}
void upd2(int l,int v,int id)
{
    if(tree2[id].l==tree2[id].r)
    {
        tree2[id].v+=v;
        tree2[id].val=tree2[id].v*b[tree2[id].l];
        return;
    }
    int mid=tree2[id].mid();
    if(l<=mid) upd2(l,v,id<<1);
    else upd2(l,v,(id<<1)|1);
    tree2[id].v=tree2[id<<1].v+tree2[(id<<1)|1].v;
    tree2[id].val=tree2[id<<1].val+tree2[(id<<1)|1].val;
}
int getk2(int k,int id)
{
    if(tree2[id].l==tree2[id].r)
        return tree2[id].l;
    int mid=tree2[id].mid();
    if(tree2[id<<1].v>=k) getk2(k,id<<1);
    else getk2(k-tree2[id<<1].v,(id<<1)|1);
}
long long query2(int l,int r,int id)
{
    if(tree2[id].l>=l&&tree2[id].r<=r)
    {
        return tree2[id].val;
    }
    int mid=tree2[id].mid();
    if(r<=mid) return query2(l,r,id<<1);
    else if(l>mid) return query2(l,r,(id<<1)|1);
    else return query2(l,mid,id<<1)+query2(mid+1,r,(id<<1)|1);
}

int bin(long long key)
{
    int l=1,r=tot,mid;
    while(l<r)
    {
        int mid=(l+r)>>1;
        if(b[mid]==key) return mid;
        else if(b[mid]>key) r=mid;
        else l=mid+1;
    }
}
long long sum[maxn];
int main()
{
    int i,j,l,r,ll,rr;
    long long tmp,tmp1,tmp2;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        sum[0]=0;
        for(i=1;i<=n;i++)
            scanf("%I64d",&a[i]),b[i]=a[i],sum[i]=sum[i-1]+a[i];
        scanf("%d",&k);
        sort(b+1,b+n+1); tot=2;
        for(i=2;i<=n;i++)
            if(b[i]!=b[i-1])
                b[tot++]=b[i];
        crt1(1,tot-1,1); crt2(1,tot-1,1);
        for(i=1;i<=m;i++)
        {
            if(a[i]>0)
                upd1(bin(a[i]),1,1);
            else
                upd2(bin(a[i]),1,1);
        }
        long long ans=-INF;
        if(k>m) k=m; long long tmp=sum[m]-sum[0];
        if(k==0) ans=max(ans,tmp);
        else
        {
            ll=getk1(k,1); tmp1=query1(ll,tot-1,1);
            rr=getk2(k,1); tmp2=query2(1,rr,1);
            ans=max(ans,max(ab(tmp-tmp1-tmp1),ab(tmp-tmp2-tmp2)));
        }
        for(;i<=n;i++)
        {
            if(a[i-m]>0)
                upd1(bin(a[i-m]),-1,1);
            else upd2(bin(a[i-m]),-1,1);
            if(a[i]>0) upd1(bin(a[i]),1,1);
            else upd2(bin(a[i]),1,1);
            tmp=sum[i]-sum[i-m];
            if(k==0) ans=max(ans,tmp);
            else
            {
                ll=getk1(k,1); tmp1=query1(ll,tot-1,1);
                rr=getk2(k,1); tmp2=query2(1,rr,1);
                ans=max(ans,max(ab(tmp-tmp1-tmp1),ab(tmp-tmp2-tmp2)));
            }
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF 10000000000000000
#define maxn 100010
struct node{
    int l,r,v;
    long long val;
    int mid(){ return (l+r)>>1; }
}tree1[maxn*4],tree2[maxn*4];
int g[maxn],n,m,k,tot;
long long a[maxn],b[maxn];
inline long long ab(long long a){ if(a>0) return a; return -a; }
void crt1(int l,int r,int id)
{
    tree1[id].l=l; tree1[id].r=r; tree1[id].v=tree1[id].val=0;
    if(l==r) return; int mid=tree1[id].mid();
    crt1(l,mid,id<<1); crt1(mid+1,r,(id<<1)|1);
}
void upd1(int l,int v,int id)
{
    if(tree1[id].l==tree1[id].r)
    {
        tree1[id].v+=v;
        tree1[id].val=tree1[id].v*b[tree1[id].l];
        return;
    }
    int mid=tree1[id].mid();
    if(l<=mid) upd1(l,v,id<<1);
    else upd1(l,v,(id<<1)|1);
    tree1[id].v=tree1[id<<1].v+tree1[(id<<1)|1].v;
    tree1[id].val=tree1[id<<1].val+tree1[(id<<1)|1].val;
}
int getk1(int k,int id)
{
    if(tree1[id].l==tree1[id].r)
        return tree1[id].l;
    int mid=tree1[id].mid();
    if(tree1[(id<<1)|1].v>=k) getk1(k,(id<<1)|1);
    else getk1(k-tree1[(id<<1)|1].v,id<<1);
}
long long query1(int l,int r,int id)
{
    if(tree1[id].l>=l&&tree1[id].r<=r)
    {
        return tree1[id].val;
    }
    int mid=tree1[id].mid();
    if(r<=mid) return query1(l,r,id<<1);
    else if(l>mid) return query1(l,r,(id<<1)|1);
    else return query1(l,mid,id<<1)+query1(mid+1,r,(id<<1)|1);
}
void crt2(int l,int r,int id)
{
    tree2[id].l=l; tree2[id].r=r; tree2[id].v=tree2[id].val=0;
    if(l==r) return; int mid=tree2[id].mid();
    crt2(l,mid,id<<1); crt2(mid+1,r,(id<<1)|1);
}
void upd2(int l,int v,int id)
{
    if(tree2[id].l==tree2[id].r)
    {
        tree2[id].v+=v;
        tree2[id].val=tree2[id].v*b[tree2[id].l];
        return;
    }
    int mid=tree2[id].mid();
    if(l<=mid) upd2(l,v,id<<1);
    else upd2(l,v,(id<<1)|1);
    tree2[id].v=tree2[id<<1].v+tree2[(id<<1)|1].v;
    tree2[id].val=tree2[id<<1].val+tree2[(id<<1)|1].val;
}
int getk2(int k,int id)
{
    if(tree2[id].l==tree2[id].r)
        return tree2[id].l;
    int mid=tree2[id].mid();
    if(tree2[id<<1].v>=k) getk2(k,id<<1);
    else getk2(k-tree2[id<<1].v,(id<<1)|1);
}
long long query2(int l,int r,int id)
{
    if(tree2[id].l>=l&&tree2[id].r<=r)
    {
        return tree2[id].val;
    }
    int mid=tree2[id].mid();
    if(r<=mid) return query2(l,r,id<<1);
    else if(l>mid) return query2(l,r,(id<<1)|1);
    else return query2(l,mid,id<<1)+query2(mid+1,r,(id<<1)|1);
}

int bin(long long key)
{
    int l=1,r=tot,mid;
    while(l<r)
    {
        int mid=(l+r)>>1;
        if(b[mid]==key) return mid;
        else if(b[mid]>key) r=mid;
        else l=mid+1;
    }
}
long long sum[maxn];
int main()
{
    int i,j,l,r,ll,rr;
    long long tmp,tmp1,tmp2;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        sum[0]=0;
        for(i=1;i<=n;i++)
            scanf("%I64d",&a[i]),b[i]=a[i],sum[i]=sum[i-1]+a[i];
        scanf("%d",&k);
        sort(b+1,b+n+1); tot=2;
        for(i=2;i<=n;i++)
            if(b[i]!=b[i-1])
                b[tot++]=b[i];
        crt1(1,tot-1,1); crt2(1,tot-1,1);
        for(i=1;i<=m;i++)
        {
            if(a[i]>0)
                upd1(bin(a[i]),1,1);
            else
                upd2(bin(a[i]),1,1);
        }
        long long ans=-INF;
        if(k>m) k=m; long long tmp=sum[m]-sum[0];
        if(k==0) ans=max(ans,ab(tmp));
        else
        {
            ll=getk1(k,1); tmp1=query1(ll,tot-1,1);
            rr=getk2(k,1); tmp2=query2(1,rr,1);
            ans=max(ans,max(ab(tmp-tmp1-tmp1),ab(tmp-tmp2-tmp2)));
        }
        for(;i<=n;i++)
        {
            if(a[i-m]>0)
                upd1(bin(a[i-m]),-1,1);
            else upd2(bin(a[i-m]),-1,1);
            if(a[i]>0) upd1(bin(a[i]),1,1);
            else upd2(bin(a[i]),1,1);
            tmp=sum[i]-sum[i-m];
            if(k==0) ans=max(ans,ab(tmp));
            else
            {
                ll=getk1(k,1); tmp1=query1(ll,tot-1,1);
                rr=getk2(k,1); tmp2=query2(1,rr,1);
                ans=max(ans,max(ab(tmp-tmp1-tmp1),ab(tmp-tmp2-tmp2)));
            }
        }
        printf("%I64d\n",ans);
    }
    return 0;
}


#include <fstream>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define forn(i,n) for (__int64 i=0;i<n;i++)
#define mp make_pair
__int64 abs(__int64 a)
{
    if (a<0) return -a;
    return a;
}
struct sNode
{
	vector <__int64> a;
	__int64 s;
	sNode *left, *right;
	sNode()
	{
		a.clear();
		s=0;
		left=right=0;
	}
};
int n,k;
sNode * prepare(vector<__int64> &mass, int l, int r)
{
	if (l>r) return 0;
	sNode *buf=new sNode;
	if (l==r)
	{
		buf->s=mass[l];
		buf->a.push_back(mass[l]);
	}
	else
	{
		int c=(l+r)/2;
		vector <__int64> a1,a2;
		if (buf->left=prepare(mass,l,c))
		{
			buf->s+=buf->left->s;
			a1=buf->left->a;
		}
		if (buf->right=prepare(mass,c+1,r))
		{
			buf->s+=buf->right->s;
			a2=buf->right->a;
		}
		buf->a.resize(a1.size()+a2.size());
		merge(a1.begin(),a1.end(),a2.begin(),a2.end(),buf->a.begin());
		if (buf->a.size()>k)
		{
			reverse(buf->a.begin(),buf->a.end());
			buf->a.resize(k);
			reverse(buf->a.begin(),buf->a.end());
		}
	}
	return buf;
}
void get(sNode *pos, int l, int r, int tl, int tr, __int64 &sum, vector <__int64> &res)
{
	if (pos==0) return;
	if (tl>r) return;
	if (l>tr) return;
	if (l==tl&&r==tr)
	{
		sum+=pos->s;
		vector <__int64> a1(res.size()+pos->a.size());
		merge(res.begin(),res.end(),pos->a.begin(),pos->a.end(),a1.begin());
		if (a1.size()>k)
		{
			reverse(a1.begin(),a1.end());
			a1.resize(k);
			reverse(a1.begin(),a1.end());
		}
		res=a1;
		return;
	}
	int c=(l+r)/2;
	get(pos->left,l,c,tl,min(c,tr),sum,res);
	get(pos->right,c+1,r,max(c+1,tl),tr,sum,res);
}
int main()
{
    ios_base::sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
    ifstream cin("input.txt");
    ofstream cout("output.txt");
	#endif
	__int64 len,q;
	cin>>n>>len;
	vector <__int64> aa(n),bb(n);
	forn(i,n)
	{
		cin>>q;
		if (q>0) aa[i]=q;
		if (q<0) bb[i]=-q;
	}
	cin>>k;
	sNode *pol=prepare(aa,0,n-1),*otr=prepare(bb,0,n-1);
	vector <__int64> res1,res2;
	__int64 s1=0,s2=0,r1,r2,res=0;
	forn(i,n-len+1)
	{
		res1.clear();
		res2.clear();
		r1=r2=s1=s2=0;
		get(pol,0,n-1,i,i+len-1,s1,res1);
		get(otr,0,n-1,i,i+len-1,s2,res2);
		forn(i,res1.size())
			r1+=res1[i];
		forn(i,res2.size())
			r2+=res2[i];
		res=max(res,abs(s1-s2));
		res=max(res,abs(s1+2*r2-s2));
		res=max(res,abs(s2+2*r1-s1));
	}
	cout<<res;
}


#include <fstream>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define forn(i,n) for (__int64 i=0;i<n;i++)
#define mp make_pair
__int64 abs(__int64 a)
{
    if (a<0) return -a;
    return a;
}
void pop(__int64 &kk, __int64 k,__int64 e, multiset<__int64> &bb, multiset<__int64> &ll, __int64 &b, __int64 &l)
{
	l-=e;
	if (bb.find(e)!=bb.end())
	{
		bb.erase(bb.find(e));
		b-=e;
		kk--;
		if (ll.begin()!=ll.end())
		{
			multiset<__int64>::iterator buf=ll.end();
			buf--;
			b+=*(buf);
			kk++;
			bb.insert(*(buf));
			ll.erase(buf);
		}
	}
	else
		ll.erase(ll.find(e));
}
void push(__int64 &kk, __int64 k,__int64 e, multiset<__int64> &bb, multiset<__int64> &ll, __int64 &b, __int64 &l)
{
	if ((k>0)&&(kk==k)&&(e>*bb.begin()))
	{
		__int64 q=*bb.begin();
		bb.erase(bb.begin());
		ll.insert(q);
		b-=q;
		kk--;
	}
	if (kk<k)
	{
		bb.insert(e);
		b+=e;
		kk++;
	}
	else
		ll.insert(e);
	l+=e;
}
int main()
{
    ios_base::sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
    ifstream cin("input.txt");
    ofstream cout("output.txt");
	#endif
	__int64 len,q,k,n;
	cin>>n>>len;
	vector <__int64> aa(n),bb(n);
	forn(i,n)
	{
		cin>>q;
		if (q>0) aa[i]=q;
		if (q<0) bb[i]=-q;
	}
	cin>>k;
	__int64 k1=0,k2=0,l1=0,l2=0,b1=0,b2=0,res=0;
	multiset<__int64> bs1,bs2,ls1,ls2;
	for (int i=0;i<n;i++)
	{
		if (i>=len)
		{
			pop(k1,k,aa[i-len],bs1,ls1,b1,l1);
			pop(k2,k,bb[i-len],bs2,ls2,b2,l2);
		}
		push(k1,k,aa[i],bs1,ls1,b1,l1);
		push(k2,k,bb[i],bs2,ls2,b2,l2);
		if (i>=len-1)
		{
			res=max(res,abs(l1-l2));
			res=max(res,abs(l1+2*b2-l2));
			res=max(res,abs(l2+2*b1-l1));
		}
	}
	cout<<res;
}


#include <fstream>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define forn(i,n) for (int i=0;i<n;i++)
#define mp make_pair
__int64 abs(__int64 a)
{
	if (a<0) return -a;
	return a;
}
int main()
{
	ios_base::sync_with_stdio(false);
	#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
	#endif
	int n,len;
	cin>>n>>len;
	vector <__int64> a(n);
	forn(i,n)
		cin>>a[i];
	__int64 k=0,k1=0,k2=0,l1=0,l2=0,b1=0,b2=0;
	cin>>k;
	multiset<__int64> ds1,ds2;
	__int64 res=0,e,q;
	for (int i=0;i<n;i++)
	{
		if (i>=len)
		{
			if (a[i-len]>=0)
			{
				e=a[i-len];
				q=ds1.erase(e);
				for (int j=0;j<q-1;j++)
					ds1.insert(e);
				if (q>0)
				{
					k1--;
					b1-=e;
				}
				l1-=e;
			}
			else
			{
				e=-a[i-len];
				q=ds2.erase(e);
				for (int j=0;j<q-1;j++)
					ds2.insert(e);
				if (q>0)
				{
					k2--;
					b2-=e;
				}
				l2-=e;
			}
		}
		if (a[i]>=0)
		{
			if (k>0)
			{
				if (k1==k&&(a[i]>*ds1.begin()))
				{
					b1-=*ds1.begin();
					ds1.erase(ds1.begin());
					k1--;
				}
				if (k1<k)
				{
					k1++;
					b1+=a[i];
					ds1.insert(a[i]);
				}
			}
			l1+=a[i];
		}
		else
		{
			if (k>0)
			{
				if (k2==k&&(-a[i]>*ds2.begin()))
				{
					b2-=*ds2.begin();
					ds2.erase(ds2.begin());
					k2--;
				}
				if (k2<k)
				{
					k2++;
					b2+=-a[i];
					ds2.insert(-a[i]);
				}
			}
			l2+=-a[i];
		}
		if (i>=len-1)
		{
			res=max(res,abs(l1-l2));
			if (k>0)
			{
				res=max(res,abs(l1+2*b2-l2));
				res=max(res,abs(l2+2*b1-l1));
			}
		}
	}
	cout<<res;
}


#include <fstream>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define forn(i,n) for (int i=0;i<n;i++)
#define mp make_pair
__int64 abs(__int64 a)
{
    if (a<0) return -a;
    return a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    #endif
    int n,len;
    cin>>n>>len;
    vector <__int64> a(n);
    forn(i,n)
    {
        cin>>a[i];
        if (a[i]==1406478710)
            cout<<"Found ya\n";
    }
    __int64 k=0,k1=0,k2=0,l1=0,l2=0,b1=0,b2=0;
    cin>>k;
    multiset<__int64> ds1,ds2;
    __int64 res=0,e,q;
    for (int i=0;i<n;i++)
    {
        if (i>=len)
        {
            if (a[i-len]>=0)
            {
                e=a[i-len];
                q=ds1.erase(e);
                for (int j=0;j<q-1;j++)
                    ds1.insert(e);
                if (q>0)
                {
                    k1--;
                    b1-=e;
                }
                l1-=e;
            }
            else
            {
                e=-a[i-len];
                q=ds2.erase(e);
                for (int j=0;j<q-1;j++)
                    ds2.insert(e);
                if (q>0)
                {
                    k2--;
                    b2-=e;
                }
                l2-=e;
            }
        }
        if (a[i]>=0)
        {
            if (k>0)
            {
                if (k1==k&&(a[i]>*ds1.begin()))
                {
                    b1-=*ds1.begin();
                    ds1.erase(ds1.begin());
                    k1--;
                }
                if (k1<k)
                {
                    k1++;
                    b1+=a[i];
                    ds1.insert(a[i]);
                }
            }
            l1+=a[i];
        }
        else
        {
            if (k>0)
            {
                if (k2==k&&(-a[i]>*ds2.begin()))
                {
                    b2-=*ds2.begin();
                    ds2.erase(ds2.begin());
                    k2--;
                }
                if (k2<k)
                {
                    k2++;
                    b2+=-a[i];
                    ds2.insert(-a[i]);
                }
            }
            l2+=-a[i];
        }
        if (i>=len-1)
        {
            res=max(res,abs(l1-l2));
            if (k>0)
            {
                res=max(res,abs(l1+2*b2-l2));
                res=max(res,abs(l2+2*b1-l1));
            }
        }
    }
    cout<<res;
    //1406478710
}


#include <fstream>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define forn(i,n) for (int i=0;i<n;i++)
#define mp make_pair
__int64 abs(__int64 a)
{
    if (a<0) return -a;
    return a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    #endif
    int n,len;
    cin>>n>>len;
    vector <__int64> a(n);
    forn(i,n)
        cin>>a[i];
    __int64 k=0,k1=0,k2=0,l1=0,l2=0,b1=0,b2=0;
    cin>>k;
    multiset<__int64> ds1,ds2;
    __int64 res=0,e,q;
    for (int i=0;i<n;i++)
    {
        if (i>=len)
        {
            if (a[i-len]>=0)
            {
                e=a[i-len];
                q=ds1.erase(e);
                for (int j=0;j<q-1;j++)
                    ds1.insert(e);
                if (q>0)
                {
                    k1--;
                    b1-=e;
                }
                l1-=e;
            }
            else
            {
                e=-a[i-len];
                q=ds2.erase(e);
                for (int j=0;j<q-1;j++)
                    ds2.insert(e);
                if (q>0)
                {
                    k2--;
                    b2-=e;
                }
                l2-=e;
            }
        }
        if (a[i]>=0)
        {
            if (k>0)
            {
                if (k1==k&&(a[i]>*ds1.begin()))
                {
                    b1-=*ds1.begin();
                    ds1.erase(ds1.begin());
                    k1--;
                }
                if (k1<k)
                {
                    k1++;
                    b1+=a[i];
                    ds1.insert(a[i]);
                }
            }
            l1+=a[i];
        }
        else
        {
            if (k>0)
            {
                if (k2==k&&(-a[i]>*ds2.begin()))
                {
                    b2-=*ds2.begin();
                    ds2.erase(ds2.begin());
                    k2--;
                }
                if (k2<k)
                {
                    k2++;
                    b2+=-a[i];
                    ds2.insert(-a[i]);
                }
            }
            l2+=-a[i];
        }
        if (i>=len-1)
        {
            res=max(res,abs(l1-l2));
            if (k>0)
            {
                res=max(res,abs(l1+2*b2-l2));
                res=max(res,abs(l2+2*b1-l1));
            }
        }
    }
    cout<<res;
}


#include <fstream>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define forn(i,n) for (__int64 i=0;i<n;i++)
#define mp make_pair
__int64 abs(__int64 a)
{
    if (a<0) return -a;
    return a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    #ifndef ONLINE_JUDGE
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    #endif
    __int64 n,len;
    cin>>n>>len;
    vector <__int64> a(n);
    forn(i,n)
        cin>>a[i];
    __int64 k=0,k1=0,k2=0,l1=0,l2=0,b1=0,b2=0;
    cin>>k;
    multiset<__int64> ds1,ds2;
    __int64 res=0,e,q;
    for (__int64 i=0;i<n;i++)
    {
        if (i>=len)
        {
            if (a[i-len]>=0)
            {
                e=a[i-len];
                q=ds1.erase(e);
                for (__int64 j=0;j<q-1;j++)
                    ds1.insert(e);
                if (q>0)
                {
                    k1--;
                    b1-=e;
                }
                l1-=e;
            }
            else
            {
                e=-a[i-len];
                q=ds2.erase(e);
                for (__int64 j=0;j<q-1;j++)
                    ds2.insert(e);
                if (q>0)
                {
                    k2--;
                    b2-=e;
                }
                l2-=e;
            }
        }
        if (a[i]>=0)
        {
            if (k>0)
            {
                if (k1==k&&(a[i]>*ds1.begin()))
                {
                    b1-=*ds1.begin();
                    ds1.erase(ds1.begin());
                    k1--;
                }
                if (k1<k)
                {
                    k1++;
                    b1+=a[i];
                    ds1.insert(a[i]);
                }
            }
            l1+=a[i];
        }
        else
        {
            if (k>0)
            {
                if (k2==k&&((-a[i])>*ds2.begin()))
                {
                    b2-=*ds2.begin();
                    ds2.erase(ds2.begin());
                    k2--;
                }
                if (k2<k)
                {
                    k2++;
                    b2+=-a[i];
                    ds2.insert(-a[i]);
                }
            }
            l2+=-a[i];
        }
        if (i>=len-1)
        {
            res=max(res,abs(l1-l2));
            if (k>0)
            {
                res=max(res,abs(l1+2*b2-l2));
                res=max(res,abs(l2+2*b1-l1));
            }
        }
    }
    cout<<res;
}


#include <fstream>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define forn(i,n) for (int i=0;i<n;i++)
#define mp make_pair
int main()
{
	ios_base::sync_with_stdio(false);
	#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
	#endif
	int n,len;
	cin>>n>>len;
	vector <int> a(n);
	forn(i,n)
		cin>>a[i];
	int k=0,k1=0,k2=0,l1=0,l2=0,b1=0,b2=0;
	cin>>k;
	multiset<int> ds1,ds2;
	int res=0;
	for (int i=0;i<n;i++)
	{
		if (i>=len)
		{
			if (a[i-len]>=0)
			{
				int e=a[i-len];
				int q=ds1.erase(e);
				for (int j=0;j<q-1;j++)
					ds1.insert(e);
				if (q>0)
				{
					k1--;
					b1-=a[i-len];
				}
				l1-=a[i-len];
			}
			else
			{
				int e=-a[i-len];
				int q=ds2.erase(e);
				for (int j=0;j<q-1;j++)
					ds2.insert(e);
				if (q>0)
				{
					k2--;
					b2-=-a[i-len];
				}
				l2-=-a[i-len];
			}
		}
		if (a[i]>=0)
		{
			if (k>0)
			{
				if (k1==k)
				{
					b1-=*ds1.begin();
					ds1.erase(ds1.begin());
					k1--;
				}
				if (k1<k)
				{
					k1++;
					b1+=a[i];
					ds1.insert(a[i]);
				}
			}
			l1+=a[i];
		}
		else
		{
			if (k>0)
			{
				if (k2==k)
				{
					b2-=*ds2.begin();
					ds2.erase(ds2.begin());
					k2--;
				}
				if (k2<k)
				{
					k2++;
					b2+=-a[i];
					ds2.insert(-a[i]);
				}
			}
			l2+=-a[i];
		}
		if (i>=len-1)
		{
			res=max(res,abs(l1-l2));
			if (k>0)
			{
				res=max(res,abs(l1+2*b2-l2));
				res=max(res,abs(l2+2*b1-l1));
			}
		}
	}
	cout<<res;
}


#include <fstream>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <deque>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
#define forn(i,n) for (int i=0;i<n;i++)
#define mp make_pair
__int64 abs(__int64 a)
{
	if (a<0) return -a;
	return a;
}
int main()
{
	ios_base::sync_with_stdio(false);
	#ifndef ONLINE_JUDGE
	ifstream cin("input.txt");
	ofstream cout("output.txt");
	#endif
	int n,len;
	cin>>n>>len;
	vector <__int64> a(n);
	forn(i,n)
		cin>>a[i];
	__int64 k=0,k1=0,k2=0,l1=0,l2=0,b1=0,b2=0;
	cin>>k;
	multiset<__int64> ds1,ds2;
	__int64 res=0,e,q;
	for (int i=0;i<n;i++)
	{
		if (i>=len)
		{
			if (a[i-len]>=0)
			{
				e=a[i-len];
				q=ds1.erase(e);
				for (int j=0;j<q-1;j++)
					ds1.insert(e);
				if (q>0)
				{
					k1--;
					b1-=a[i-len];
				}
				l1-=a[i-len];
			}
			else
			{
				e=-a[i-len];
				q=ds2.erase(e);
				for (int j=0;j<q-1;j++)
					ds2.insert(e);
				if (q>0)
				{
					k2--;
					b2-=-a[i-len];
				}
				l2-=-a[i-len];
			}
		}
		if (a[i]>=0)
		{
			if (k>0)
			{
				if (k1==k)
				{
					b1-=*ds1.begin();
					ds1.erase(ds1.begin());
					k1--;
				}
				if (k1<k)
				{
					k1++;
					b1+=a[i];
					ds1.insert(a[i]);
				}
			}
			l1+=a[i];
		}
		else
		{
			if (k>0)
			{
				if (k2==k)
				{
					b2-=*ds2.begin();
					ds2.erase(ds2.begin());
					k2--;
				}
				if (k2<k)
				{
					k2++;
					b2+=-a[i];
					ds2.insert(-a[i]);
				}
			}
			l2+=-a[i];
		}
		if (i>=len-1)
		{
			res=max(res,abs(l1-l2));
			if (k>0)
			{
				res=max(res,abs(l1+2*b2-l2));
				res=max(res,abs(l2+2*b1-l1));
			}
		}
	}
	cout<<res;
}


#pragma comment(linker,"/STACK:300000000")
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:4800)

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <memory.h>
#include <cstdio>
#include <sstream>
#include <deque>
#include <bitset>
#include <numeric>
#include <ctime>
#include <queue>

using namespace std;

#define show(x) cout << #x << " = " << (x) << endl;
#define fori(i,n) for(int i = 0; i < (n); i++)
#define forab(i,a,b) for(int i = (a); i <= (b); i++)
#define sz(v) int((v).size())
#define all(v) (v).begin(),(v).end()
const double pi = 3.1415926535897932384626433832795;
template<class T> T abs(const T &a) { return a >= 0 ? a : -a; };
template<class T> T sqr(const T &x) { return x * x; }
typedef pair<int,int> ii;
typedef long long ll;
///////////////////////////////////////

int n, len, k;
vector<ll> a;
multiset<ll> qmi, qma;

ll add(ll val)
{
    if(val >= 0)
        throw 0;
    if(sz(qmi) < k)
    {
        qmi.insert(val);
        return -val;
    }
    else
    {
        if(k > 0 && val < *(--qmi.end()))
        {
            ll ret = -val - 2*(-(*(--qmi.end())));
            qma.insert(*(--qmi.end()));
            qmi.erase(--qmi.end());
            qmi.insert(val);
            return ret;
        }
        else
        {
            qma.insert(val);
            return val;
        }
    }
}

ll remove(ll val)
{
    if(val >= 0)
        throw 0;
    if(qmi.find(val) != qmi.end())
    {
        ll ret = val;
        qmi.erase(qmi.find(val));
        if(!qma.empty())
        {
            ret -= 2*(*qma.begin());
            qmi.insert(*qma.begin());
            qma.erase(qma.begin());
        }
        return ret;
    }
    else
    {
        qma.erase(qma.find(val));
        return -val;
    }
}

ll f()
{
    ll curAns = 0;
    fori(i,len)
        if(a[i] >= 0)
            curAns += a[i];
        else
            curAns += add(a[i]);
    ll ma = 0;
    for(int start = 0; start+len-1 < n; start++)
    {
        ma = max(ma,curAns);
        if(a[start] >= 0)
            curAns -= a[start];
        else
            curAns += remove(a[start]);
        if(start+len-1 != n-1)
        {
            if(a[start+len] >= 0)
                curAns += a[start+len];
            else
                curAns += add(a[start+len]);
        }
    }
    return ma;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    cin >> n >> len;
    a.resize(n);
    fori(i,n)
        cin >> a[i];
    cin >> k;

    ll ans = f();
    fori(i,sz(a))
        a[i] *= -1;
    qmi.clear();
    qma.clear();
    ans = max(ans,f());
    cout << ans;
}


#pragma comment(linker,"/STACK:300000000")
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:4800)

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <memory.h>
#include <cstdio>
#include <sstream>
#include <deque>
#include <bitset>
#include <numeric>
#include <ctime>
#include <queue>

using namespace std;

#define show(x) cout << #x << " = " << (x) << endl;
#define fori(i,n) for(int i = 0; i < (n); i++)
#define forab(i,a,b) for(int i = (a); i <= (b); i++)
#define sz(v) int((v).size())
#define all(v) (v).begin(),(v).end()
const double pi = 3.1415926535897932384626433832795;
template<class T> T abs(const T &a) { return a >= 0 ? a : -a; };
template<class T> T sqr(const T &x) { return x * x; }
typedef pair<int,int> ii;
typedef long long ll;
///////////////////////////////////////

int n, len, k;
vector<int> a;
multiset<int> q;

ll add(int val)
{
    if(val >= 0)
        throw 0;
    if(sz(q) < k)
    {
        q.insert(val);
        return -val;
    }
    else if(val < *(--q.end()))
    {
        int ret = -val - -(*(--q.end()));
        q.erase(--q.end());
        q.insert(val);
        return ret;
    }
    else
        return 0;
}

ll f()
{
    ll curAns = 0;
    fori(i,len)
        if(a[i] >= 0)
            curAns += a[i];
        else
            curAns += add(a[i]);
    ll ma = 0;
    for(int start = 0; start+len-1 < n; start++)
    {
        ma = max(ma,curAns);
        if(a[start] >= 0)
            curAns -= a[start];
        else if(q.count(a[start]))
        {
            curAns += a[start];
            q.erase(q.find(a[start]));
        }
        if(start+len-1 != n-1)
        {
            if(a[start+len] >= 0)
                curAns += a[start+len];
            else
                curAns += add(a[start+len]);
        }
    }
    return ma;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    cin >> n >> len;
    a.resize(n);
    fori(i,n)
        cin >> a[i];
    cin >> k;

    ll ans = f();
    fori(i,sz(a))
        a[i] *= -1;
    q.clear();
    ans = max(ans,f());
    cout << ans;
}


#pragma comment(linker,"/STACK:300000000")
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:4800)

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <memory.h>
#include <cstdio>
#include <sstream>
#include <deque>
#include <bitset>
#include <numeric>
#include <ctime>
#include <queue>

using namespace std;

#define show(x) cout << #x << " = " << (x) << endl;
#define fori(i,n) for(int i = 0; i < (n); i++)
#define forab(i,a,b) for(int i = (a); i <= (b); i++)
#define sz(v) int((v).size())
#define all(v) (v).begin(),(v).end()
const double pi = 3.1415926535897932384626433832795;
template<class T> T abs(const T &a) { return a >= 0 ? a : -a; };
template<class T> T sqr(const T &x) { return x * x; }
typedef pair<int,int> ii;
typedef long long ll;
///////////////////////////////////////

int n, len, k;
vector<int> a;
multiset<int> qmi, qma;

ll add(int val)
{
    if(val >= 0)
        throw 0;
    if(sz(qmi) < k)
    {
        qmi.insert(val);
        return -val;
    }
    else
    {
        if(k > 0 && val < *(--qmi.end()))
        {
            ll ret = -val - 2*(-(*(--qmi.end())));
            qma.insert(*(--qmi.end()));
            qmi.erase(--qmi.end());
            qmi.insert(val);
            return ret;
        }
        else
        {
            qma.insert(val);
            return val;
        }
    }
}

ll remove(int val)
{
    if(val >= 0)
        throw 0;
    if(qmi.find(val) != qmi.end())
    {
        ll ret = val;
        qmi.erase(qmi.find(val));
        if(!qma.empty())
        {
            ret -= *qma.begin();
            qmi.insert(*qma.begin());
            qma.erase(qma.begin());
        }
        return ret;
    }
    else
    {
        qma.erase(qma.find(val));
        return -val;
    }
}

ll f()
{
    ll curAns = 0;
    fori(i,len)
        if(a[i] >= 0)
            curAns += a[i];
        else
            curAns += add(a[i]);
    ll ma = 0;
    for(int start = 0; start+len-1 < n; start++)
    {
        ma = max(ma,curAns);
        if(a[start] >= 0)
            curAns -= a[start];
        else
            curAns += remove(a[start]);
        if(start+len-1 != n-1)
        {
            if(a[start+len] >= 0)
                curAns += a[start+len];
            else
                curAns += add(a[start+len]);
        }
    }
    return ma;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    cin >> n >> len;
    a.resize(n);
    fori(i,n)
        cin >> a[i];
    cin >> k;

    ll ans = f();
    fori(i,sz(a))
        a[i] *= -1;
    qmi.clear();
    qma.clear();
    ans = max(ans,f());
    cout << ans;
}


#pragma comment(linker,"/STACK:300000000")
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:4800)

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <memory.h>
#include <cstdio>
#include <sstream>
#include <deque>
#include <bitset>
#include <numeric>
#include <ctime>
#include <queue>

using namespace std;

#define show(x) cout << #x << " = " << (x) << endl;
#define fori(i,n) for(int i = 0; i < (n); i++)
#define forab(i,a,b) for(int i = (a); i <= (b); i++)
#define sz(v) int((v).size())
#define all(v) (v).begin(),(v).end()
const double pi = 3.1415926535897932384626433832795;
template<class T> T abs(const T &a) { return a >= 0 ? a : -a; };
template<class T> T sqr(const T &x) { return x * x; }
typedef pair<int,int> ii;
typedef long long ll;
///////////////////////////////////////

int n, len, k;
vector<ll> a;
multiset<ll> qmi, qma;

ll add(ll val)
{
    if(val >= 0)
        throw 0;
    if(sz(qmi) < k)
    {
        qmi.insert(val);
        return -val;
    }
    else
    {
        if(k > 0 && val < *(--qmi.end()))
        {
            ll ret = ll(-val) - ll(2*(-(*(--qmi.end()))));
            qma.insert(*(--qmi.end()));
            qmi.erase(--qmi.end());
            qmi.insert(val);
            return ret;
        }
        else
        {
            qma.insert(val);
            return val;
        }
    }
}

ll remove(ll val)
{
    if(val >= 0)
        throw 0;
    if(qmi.find(val) != qmi.end())
    {
        ll ret = val;
        qmi.erase(qmi.find(val));
        if(!qma.empty())
        {
            ret -= *qma.begin();
            qmi.insert(*qma.begin());
            qma.erase(qma.begin());
        }
        return ret;
    }
    else
    {
        qma.erase(qma.find(val));
        return -val;
    }
}

ll f()
{
    ll curAns = 0;
    fori(i,len)
        if(a[i] >= 0)
            curAns += a[i];
        else
            curAns += add(a[i]);
    ll ma = 0;
    for(int start = 0; start+len-1 < n; start++)
    {
        ma = max(ma,curAns);
        if(a[start] >= 0)
            curAns -= a[start];
        else
            curAns += remove(a[start]);
        if(start+len-1 != n-1)
        {
            if(a[start+len] >= 0)
                curAns += a[start+len];
            else
                curAns += add(a[start+len]);
        }
    }
    return ma;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    cin >> n >> len;
    a.resize(n);
    fori(i,n)
        cin >> a[i];
    cin >> k;

    ll ans = f();
    fori(i,sz(a))
        a[i] *= -1;
    qmi.clear();
    qma.clear();
    ans = max(ans,f());
    cout << ans;
}


#pragma comment(linker,"/STACK:300000000")
#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:4800)

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <memory.h>
#include <cstdio>
#include <sstream>
#include <deque>
#include <bitset>
#include <numeric>
#include <ctime>
#include <queue>

using namespace std;

#define show(x) cout << #x << " = " << (x) << endl;
#define fori(i,n) for(int i = 0; i < (n); i++)
#define forab(i,a,b) for(int i = (a); i <= (b); i++)
#define sz(v) int((v).size())
#define all(v) (v).begin(),(v).end()
const double pi = 3.1415926535897932384626433832795;
template<class T> T abs(const T &a) { return a >= 0 ? a : -a; };
template<class T> T sqr(const T &x) { return x * x; }
typedef pair<int,int> ii;
typedef long long ll;
///////////////////////////////////////

int n, len, k;
vector<int> a;
multiset<int> q;

ll add(int val)
{
    if(val >= 0)
        throw 0;
    if(sz(q) < k)
    {
        q.insert(val);
        return -val;
    }
    else if(val < *(--q.end()))
    {
        int ret = -val - -(*(--q.end()));
        q.erase(--q.end());
        q.insert(val);
        return ret;
    }
    else
        return 0;
}

ll f()
{
    ll curAns = 0;
    fori(i,len)
        if(a[i] >= 0)
            curAns += a[i];
        else
            curAns += add(a[i]);
    ll ma = 0;
    for(int start = 0; start+len-1 < n; start++)
    {
        ma = max(ma,curAns);
        if(a[start] >= 0)
            curAns -= a[start];
        else if(q.count(a[start]))
        {
            curAns += a[start];
            q.erase(q.find(a[start]));
        }
        if(start+len-1 != n-1)
        {
            if(a[start+len] >= 0)
                curAns += a[start+len];
            else
                curAns += add(a[start+len]);
        }
    }
    return ma;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    cin >> n >> len;
    a.resize(n);
    fori(i,n)
        cin >> a[i];
    cin >> k;

    ll ans = f();
    fori(i,sz(a))
        a[i] *= -1;
    ans = max(ans,f());
    cout << ans;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define PI pair<int, int>
#define MP make_pair

const double eps = 1e-10;
const int INF = 1111111111;
const int maxn = 100100;

using namespace std;

struct tt
{
	int ll, rr, cnt;
	__int64 sum;
} p1[maxn*4], p2[maxn*4];

void build( int s, int e, int num, tt* p )
{
	p[num].ll = s;	p[num].rr = e;
	p[num].sum = 0;	p[num].cnt = 0;

	if( s - e )
	{
		int m = (s+e)/2;
		build(s, m, num*2+1, p);
		build(m+1, e, num*2+2, p);
	}
}

void update( int pos, int val, int num, tt* p )
{
	if( p[num].ll == p[num].rr )
	{
		if( val == INF )
		{
			p[num].sum = 0;
			p[num].cnt = 0;
		}
		else
		{
			p[num].sum = val;
			p[num].cnt++;
		}
		return;
	}

	if( p[num*2+1].rr <= pos )
		update(pos, val, num*2+1, p);
	else
		update(pos, val, num*2+2, p);

	p[num].sum = p[num*2+1].sum + p[num*2+2].sum;
	p[num].cnt = p[num*2+1].cnt + p[num*2+2].cnt;
}

__int64 query( int k, int num, tt* p )
{
	if( p[num].cnt <= k )
		return p[num].sum;

	if( p[num*2+2].cnt >= k )
		return query(k, num*2+2, p);
	else
		return query(k-p[num*2+2].cnt, num*2+1, p) + p[num*2+2].sum;
}

struct ttt
{
	int val, pos, id;
} a[maxn];

int cmp1( ttt x, ttt y )
{
	return x.val < y.val;
}

int cmp2( ttt x, ttt y )
{
	return x.id < y.id;
}

int main()
{
	int i, j, k, n, len, e1, e2;
	__int64 ans, t, s1, s2;

	while( cin >> n >> len )
	{
		e1 = e2 = 0;
		for( i = 0; i < n; ++i )
		{
			cin >> a[i].val;
			a[i].id = i;
		}
		cin >> k;
		sort(a, a+n, cmp1);

		for( t = 0; t < n; ++t )
			if( a[t].val >= 0 )
				break;

		for( i = t-1, e2 = 0; i >= 0; --i, e2++ )
			a[i].pos = e2;
		for( i = t, e1 = 0; i < n; ++i, ++e1 )
			a[i].pos = e1;

		sort(a, a+n, cmp2);

		s1 = s2 = 0;
		build(0, e1, 0, p1);
		build(0, e2, 0, p2);
		for( i = 0; i < len; ++i )
		{
			if( a[i].val >= 0 )
				update(a[i].pos, a[i].val, 0, p1);
			else
				update(a[i].pos, -a[i].val, 0, p2);
			s1 += a[i].val;
			s2 -= a[i].val;
		}
		ans = s1 + 2*query(k, 0, p2);
		t = s2 + 2*query(k, 0, p1);
		if( t > ans )	ans = t;

		for( ; i < n; ++i )
		{
			if( a[i-len].val >= 0 )
				update(a[i-len].pos, INF, 0, p1);
			else
				update(a[i-len].pos, INF, 0, p2);
			s1 -= a[i-len].val;
			s2 += a[i-len].val;

			if( a[i].val >= 0 )
				update(a[i].pos, a[i].val, 0, p1);
			else
				update(a[i].pos, -a[i].val, 0, p2);
			s1 += a[i].val;
			s2 -= a[i].val;

			t = s1 + 2*query(k, 0, p2);
			if( t > ans )	ans = t;

			t = s2 + 2*query(k, 0, p1);
			if( t > ans )	ans = t;
		}

		printf("%I64d\n", ans);
	}

	return 0;
}


#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define PI pair<int, int>
#define MP make_pair

const double eps = 1e-10;
const int INF = 1111111111;
const int maxn = 100100;

using namespace std;

struct tt
{
    int ll, rr, cnt;
    __int64 sum;
} p1[maxn*4], p2[maxn*4];

void build( int s, int e, int num, tt* p )
{
    p[num].ll = s;  p[num].rr = e;
    p[num].sum = 0; p[num].cnt = 0;

    if( s - e )
    {
        int m = (s+e)/2;
        build(s, m, num*2+1, p);
        build(m+1, e, num*2+2, p);
    }
}

void update( int pos, int val, int num, tt* p )
{
    if( p[num].ll == p[num].rr )
    {
        if( val == INF )
        {
            p[num].sum = 0;
            p[num].cnt = 0;
        }
        else
        {
            p[num].sum = val;
            p[num].cnt++;
        }
        return;
    }

    if( p[num*2+1].rr >= pos )
        update(pos, val, num*2+1, p);
    else
        update(pos, val, num*2+2, p);

    p[num].sum = p[num*2+1].sum + p[num*2+2].sum;
    p[num].cnt = p[num*2+1].cnt + p[num*2+2].cnt;
}

__int64 query( int k, int num, tt* p )
{
    if( p[num].cnt <= k )
        return p[num].sum;

    if( p[num*2+2].cnt >= k )
        return query(k, num*2+2, p);
    else
        return query(k-p[num*2+2].cnt, num*2+1, p) + p[num*2+2].sum;
}

struct ttt
{
    int val, pos, id;
} a[maxn];

int cmp1( ttt x, ttt y )
{
    return x.val < y.val;
}

int cmp2( ttt x, ttt y )
{
    return x.id < y.id;
}

int main()
{
    int i, j, k, n, len, e1, e2;
    __int64 ans, t, s1, s2;

    while( cin >> n >> len )
    {
        e1 = e2 = 0;
        for( i = 0; i < n; ++i )
        {
            cin >> a[i].val;
            a[i].id = i;
        }
        cin >> k;
        sort(a, a+n, cmp1);

        for( t = 0; t < n; ++t )
            if( a[t].val >= 0 )
                break;

        for( i = t-1, e2 = 0; i >= 0; --i, e2++ )
            a[i].pos = e2;
        for( i = t, e1 = 0; i < n; ++i, ++e1 )
            a[i].pos = e1;

        sort(a, a+n, cmp2);

        s1 = s2 = 0;
        build(0, e1, 0, p1);
        build(0, e2, 0, p2);
        for( i = 0; i < len; ++i )
        {
            if( a[i].val >= 0 )
                update(a[i].pos, a[i].val, 0, p1);
            else
                update(a[i].pos, -a[i].val, 0, p2);
            s1 += a[i].val;
            s2 -= a[i].val;
        }
        ans = s1 + 2*query(k, 0, p2);
        t = s2 + 2*query(k, 0, p1);
        if( t > ans )   ans = t;

        for( ; i < n; ++i )
        {
            if( a[i-len].val >= 0 )
                update(a[i-len].pos, INF, 0, p1);
            else
                update(a[i-len].pos, INF, 0, p2);
            s1 -= a[i-len].val;
            s2 += a[i-len].val;

            if( a[i].val >= 0 )
                update(a[i].pos, a[i].val, 0, p1);
            else
                update(a[i].pos, -a[i].val, 0, p2);
            s1 += a[i].val;
            s2 -= a[i].val;

            t = s1 + 2*query(k, 0, p2);
            if( t > ans )   ans = t;

            t = s2 + 2*query(k, 0, p1);
            if( t > ans )   ans = t;
        }

        printf("%I64d\n", ans);
    }

    return 0;
}


#include <set>
#include <iostream>

using namespace std;

struct Set {
    int c;
    long long slo, shi;
    multiset<long long> hi;
    multiset<long long, greater<long long> > lo;

    void init(int n) {
        c = n;
        slo = shi = 0LL;
    }

    void insert(long long x) {
        hi.insert(x);
        shi += x;
        if ((int)hi.size() > c) {
            x = *hi.begin();
            hi.erase(hi.begin());
            lo.insert(x);
            shi -= x;
            slo += x;
        }
    }

    void erase(long long x) {
        if (lo.count(x) > 0) {
            lo.erase(lo.find(x));
            slo -= x;
        } else {
            hi.erase(hi.find(x));
            shi -= x;
            if (!lo.empty()) {
                x = *lo.begin();
                lo.erase(lo.begin());
                hi.insert(x);
                slo -= x;
                shi += x;
            }
        }
    }
} pos, neg;

const int MAXN = 100100;

long long a[MAXN];

void insert(long long x) {
    if (x >= 0) {
        pos.insert(x);
    } else {
        neg.insert(-x);
    }
}

void erase(long long x) {
    if (x >= 0) {
        pos.erase(x);
    } else {
        neg.erase(-x);
    }
}

long long query() {
    return max(
            pos.shi + pos.slo + neg.shi - neg.slo,
            neg.shi + neg.slo + pos.shi - pos.slo);
}

int main() {
    int n, m, k;
    long long ans = 0;

    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    cin >> k;
    pos.init(k);
    neg.init(k);
    for (int i = 0; i < n; ++i) {
        if (i >= m) {
            erase(a[i - m]);
        }
        insert(a[i]);
        if (i >= m) {
            ans = max(ans, query());
        } else if (i == m - 1) {
            ans = query();
        }
    }
    cout << ans << endl;

    return 0;
}


#include<iostream>
#include<algorithm>
#define N 100005
#define MAX(a,b) ((a)>(b)?(a):(b))
#define LL long long
using namespace std;
struct node{
	int  val,id;
	bool operator <(const node&a)const
	{
		if(val==a.val)
			return id<a.id;
		return val<a.val;
	}
}b[N];
int a[N],pos[N],num[N*3];
LL tree[N*3];
int n,k,len;
LL solve()
{
	LL ans,tp,sum;
	int i,j,m,s;
	tp=0;
	for(i=1;i<=n;i++)
	{
		b[i].val=a[i];
		b[i].id=i;
	}
	sort(b+1,b+n+1);
	for(i=1;i<=n;i++)
		pos[b[i].id]=i;
	memset(tree,0,sizeof(tree));
	memset(num,0,sizeof(num));
	for(s=1;s<n;s<<=1);
	s--;
	for(i=1;i<len;i++)
	{
		if(a[i]<0)
			for(j=s+pos[i];j;j>>=1)
				tree[j]+=a[i],num[j]++;
		tp+=a[i];
	}
	for(i=len;i<=n;i++)
	{
		tp+=a[i]-a[i-len];
		if(a[i-len]<0)
			for(j=s+pos[i-len];j;j>>=1)
				tree[j]-=a[i-len],num[j]--;
		if(a[i]<0)
			for(j=s+pos[i];j;j>>=1)
				tree[j]+=a[i],num[j]++;
		j=k;
		sum=0;
			for(m=1;m<=n+s;)
			{
				if(num[m]<=j)
				{
					sum+=tree[m];
					break;
				}
				if(num[2*m]>=j)
					m*=2;
				else
				{
					sum+=tree[2*m];
					j-=num[2*m];
					m=2*m+1;
				}
			}
		if(i==len||ans<tp-sum*2)
			ans=tp-sum*2;
	}
	return ans;
}
int main()
{
	LL ans;
	cin>>n>>len;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	cin>>k;
	ans=solve();
	for(int i=1;i<=n;i++)
		a[i]=-a[i];
	ans=MAX(ans,solve());
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#define N 100005
#define MAX(a,b) ((a)>(b)?(a):(b))
#define LL long long
using namespace std;
struct node{
	int val,id;
	bool operator <(const node&a)const
	{
		if(val==a.val)
			return id<a.id;
		return val<a.val;
	}
}b[N];
int a[N],pos[N],tree[N*3],num[N*3];
int n,k,len;
LL solve()
{
	LL ans,tp,sum;
	int i,j,m,s;
	tp=0;
	for(i=1;i<=n;i++)
	{
		b[i].val=a[i];
		b[i].id=i;
	}
	sort(b+1,b+n+1);
	for(i=1;i<=n;i++)
		pos[b[i].id]=i;
	memset(tree,0,sizeof(tree));
	memset(num,0,sizeof(num));
	for(s=1;s<n;s<<=1);
	s--;
	for(i=1;i<len;i++)
	{
		if(a[i]<0)
			for(j=s+pos[i];j;j>>=1)
				tree[j]+=a[i],num[j]++;
		tp+=a[i];
	}
	for(i=len;i<=n;i++)
	{
		tp+=a[i]-a[i-len];
		if(a[i-len]<0)
			for(j=s+pos[i-len];j;j>>=1)
				tree[j]-=a[i-len],num[j]--;
		if(a[i]<0)
			for(j=s+pos[i];j;j>>=1)
				tree[j]+=a[i],num[j]++;
		j=k;
		sum=0;
		if(k)
		{
			for(m=1;m<=n+s;)
			{
				if(num[m]<=j)
				{
					sum+=tree[m];
					break;
				}
				if(num[2*m]>=j)
					m*=2;
				else
				{
					sum+=tree[2*m];
					j-=num[2*m];
					m=2*m+1;
				}
			}
		}
		if(i==len||ans<tp-sum*2)
			ans=tp-sum*2;
	}
	return ans;
}
int main()
{
	LL ans;
	cin>>n>>len;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	cin>>k;
	ans=solve();
	for(int i=1;i<=n;i++)
		a[i]=-a[i];
	ans=MAX(ans,solve());
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#define N 100005
#define MAX(a,b) ((a)>(b)?(a):(b))
#define LL long long
using namespace std;
struct node{
	int val,id;
	bool operator <(const node&a)const
	{
		if(val==a.val)
			return id<a.id;
		return val<a.val;
	}
}b[N];
int a[N],pos[N],tree[N*3],num[N*3];
int n,k,len;
LL solve()
{
	LL ans,tp,sum;
	int i,j,m,s;
	tp=0;
	for(i=1;i<=n;i++)
	{
		b[i].val=a[i];
		b[i].id=i;
	}
	sort(b+1,b+n+1);
	for(i=1;i<=n;i++)
		pos[b[i].id]=i;
	memset(tree,0,sizeof(tree));
	memset(num,0,sizeof(num));
	for(s=1;s<n;s<<=1);
	s--;
	for(i=1;i<len;i++)
	{
		if(a[i]<0)
			for(j=s+pos[i];j;j>>=1)
				tree[j]+=a[i],num[j]++;
		tp+=a[i];
	}
	for(i=len;i<=n;i++)
	{
		tp+=a[i]-a[i-len];
		if(a[i-len]<0)
			for(j=s+pos[i-len];j;j>>=1)
				tree[j]-=a[i-len],num[j]--;
		if(a[i]<0)
			for(j=s+pos[i];j;j>>=1)
				tree[j]+=a[i],num[j]++;
		j=k;
		sum=0;
		for(m=1;m<=n;)
		{
			if(num[m]<=j)
			{
				sum+=tree[m];
				break;
			}
			if(num[2*m]>=j)
				m*=2;
			else
			{
				sum+=tree[2*m];
				j-=num[2*m];
				m=2*m+1;
			}
		}
		if(i==len||ans<tp-sum*2)
			ans=tp-sum*2;
	}
	return ans;
}
int main()
{
	LL ans;
	cin>>n>>len;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	cin>>k;
	ans=solve();
	for(int i=1;i<=n;i++)
		a[i]=-a[i];
	ans=MAX(ans,solve());
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#define N 100005
#define MAX(a,b) ((a)>(b)?(a):(b))
#define LL long long
using namespace std;
struct node{
	int val,id;
	bool operator <(const node&a)const
	{
		if(val==a.val)
			return id<a.id;
		return val<a.val;
	}
}b[N];
int a[N],pos[N],tree[N*3],num[N*3];
int n,k,len;
LL solve()
{
	LL ans,tp,sum;
	int i,j,m,s;
	tp=0;
	for(i=1;i<=n;i++)
	{
		b[i].val=a[i];
		b[i].id=i;
	}
	sort(b+1,b+n+1);
	for(i=1;i<=n;i++)
		pos[b[i].id]=i;
	memset(tree,0,sizeof(tree));
	memset(num,0,sizeof(num));
	for(s=1;s<n;s<<=1);
	s--;
	for(i=1;i<len;i++)
	{
		if(a[i]<0)
			for(j=s+pos[i];j;j>>=1)
				tree[j]+=a[i],num[j]++;
		tp+=a[i];
	}
	for(i=len;i<=n;i++)
	{
		tp+=a[i]-a[i-len];
		if(a[i-len]<0)
			for(j=s+pos[i-len];j;j>>=1)
				tree[j]-=a[i-len],num[j]--;
		if(a[i]<0)
			for(j=s+pos[i];j;j>>=1)
				tree[j]+=a[i],num[j]++;
		j=k;
		sum=0;
		for(m=1;m<=n+s;)
		{
			if(num[m]<=j)
			{
				sum+=tree[m];
				break;
			}
			if(num[2*m]>=j)
				m*=2;
			else
			{
				sum+=tree[2*m];
				j-=num[2*m];
				m=2*m+1;
			}
		}
		if(i==len||ans<tp-sum*2)
			ans=tp-sum*2;
	}
	return ans;
}
int main()
{
	LL ans;
	cin>>n>>len;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	cin>>k;
	ans=solve();
	for(int i=1;i<=n;i++)
		a[i]=-a[i];
	ans=MAX(ans,solve());
	cout<<ans<<endl;
	return 0;
}


// from watashi's solution
#include <set>
#include <iostream>

using namespace std;

struct Set {
    int c;
    long long slo, shi;
    multiset<long long> hi;
    multiset<long long, greater<long long> > lo;

    void init(int n) {
        c = n;
        slo = shi = 0LL;
    }

    void insert(long long x) {
        hi.insert(x);
        shi += x;
        if ((int)hi.size() > c) {
            x = *hi.begin();
            hi.erase(hi.begin());
            lo.insert(x);
            shi -= x;
            slo += x;
        }
    }

    void erase(long long x) {
        if (lo.count(x) > 0) {
            lo.erase(lo.find(x));
            slo -= x;
        } else {
            hi.erase(hi.find(x));
            shi -= x;
            if (!lo.empty()) {
                x = *lo.begin();
                lo.erase(lo.begin());
                hi.insert(x);
                slo -= x;
                shi += x;
            }
        }
    }
} pos, neg;

const int MAXN = 100100;

long long a[MAXN];

void insert(long long x) {
    if (x >= 0) {
        pos.insert(x);
    } else {
        neg.insert(-x);
    }
}

void erase(long long x) {
    if (x >= 0) {
        pos.erase(x);
    } else {
        neg.erase(-x);
    }
}

long long query() {
    return max(
        pos.shi + pos.slo + neg.shi - neg.slo,
        neg.shi + neg.slo + pos.shi - pos.slo);
}

int main() {
    int n, m, k;
    long long ans = 0;

    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    cin >> k;
    pos.init(k);
    neg.init(k);
    for (int i = 0; i < n; ++i) {
        if (i >= m) {
            erase(a[i - m]);
        }
        insert(a[i]);
        if (i >= m) {
            ans = max(ans, query());
        } else if (i == m - 1) {
            ans = query();
        }
    }
    cout << ans << endl;

    return 0;
}

//#include <algorithm>
//#include <functional>
//#include <numeric>
//#include <iostream>
//#include <iomanip>
//#include <sstream>
//#include <string>
//#include <vector>
//#include <queue>
//#include <stack>
//#include <cmath>
//#include <cassert>
//#include <bitset>
//#include <set>
//#include <map>
//
//using namespace std;
//
//#define MAXN 100005
//long long a[MAXN];
//int n, len, k;
//typedef pair<long long, int> PI;
//typedef map<PI, bool> MC;
//MC m,m1,m2;
//
//long long myabs(long long num)
//{
//  if (num<0LL) return -num;
//  return num;
//}
//
////// this does not work since map does not support iterator + k
////long long solve()
////{
////  m1.clear(); m2.clear();
////  long long curr = 0;
////  for(int i = 0; i < len; i ++)
////  {
////    curr += a[i];
////    if (a[i]>0) // keep positive
////      m1[make_pair(a[i], i)] = true;
////    if (a[i]<0) // keep negative
////      m2[make_pair(a[i], i)] = true;
////  }
////  long long ans = myabs(curr);
////  long long max1=0, max2=0;
////  int k1=k,k2=k;
////  // the maximum gain we can get by turning positive numbers to negative
////  for(MC::reverse_iterator rit = m1.rbegin(); rit != m1.rend() && k1>0; rit++)
////  {
////    max1 = max1 + rit->first.first;
////    k1--;
////  }
////  // the maximum gain we can get by turning negative numbers to positive
////  for(MC::iterator it = m2.begin(); it != m2.end() && k2>0; it++)
////  {
////    max2 = max2 - it->first.first;
////    k2--;
////  }
////
////  for(int i = len; i <= n; i ++)
////  {
////    if (curr>=0)
////      ans = max(ans, curr+2LL*max2);
////    if (curr<=0)
////      ans = max(ans, curr+2LL*max1);
////    if (i==n) break;
////    if (a[i-len]>0)
////    {
////      /*if (m1.size()<=k || (int)(m1.find(make_pair(a[i-len],i-len)) - m1.begin())>=((int)m1.size()-k))*/
////      if (m1.size()<=k)
////        max1 -= a[i-len];
////      m1.erase(make_pair(a[i-len],i-len));
////    }
////    else if (a[i-len]<0)
////    {
////      /*if (m2.size()<=k || (int)(m2.find(make_pair(a[i-len],i-len)) - m2.begin())<k)
////        max2 += a[i-len];*/
////      m2.erase(make_pair(a[i-len],i-len));
////    }
////    if (a[i]>0)
////    {
////      /*if (m1.size()<=k || (int)(m1.find(make_pair(a[i],i)) - m1.begin())>=((int)m1.size()-k))
////        max1 += a[i];*/
////      m1[make_pair(a[i], i)] = true;
////    }
////    else if (a[i]<0)
////    {
////      /*if (m2.size()<=k || (int)(m2.find(make_pair(a[i],i)) - m2.begin())<k)
////        max2 -= a[i];*/
////      m2[make_pair(a[i], i)] = true;
////    }
////    curr -= a[i-len];
////    curr += a[i];
////  }
////  return ans;
////}
//
//// TLE
//long long solve()
//{
//  m.clear();
//  long long curr = 0;
//  for(int i = 0; i < len; i ++)
//  {
//    curr += a[i];
//    m[make_pair(a[i], i)] = true;
//  }
//  long long ans = myabs(curr);
//  for(int i = len; i <= n; i ++)
//  {
//    if (curr>=0)
//    {
//      long long tmp = curr;
//      int k0=k;
//      for(MC::iterator it = m.begin(); it != m.end() && k0>0; it++)
//      {
//        if (it->first.first>=0) break;
//        tmp = tmp - 2LL*(it->first.first);
//        k0--;
//      }
//      ans = max(ans, myabs(tmp));
//    }
//    if (curr<=0)
//    {
//      long long tmp = curr;
//      int k0=k;
//      for(MC::reverse_iterator it = m.rbegin(); it != m.rend() && k0>0; it++)
//      {
//        if(it->first.first<=0) break;
//        tmp = tmp - 2LL*(it->first.first);
//        k0--;
//      }
//      ans = max(ans, myabs(tmp));
//    }
//    if (i==n) break;
//    m.erase(make_pair(a[i-len],i-len));
//    m[make_pair(a[i], i)] = true;
//    curr -= a[i-len];
//    curr += a[i];
//  }
//  return ans;
//}
//
//int main()
//{
//  //freopen("input.txt","r",stdin);
//  cin >> n >> len;
//  for(int i = 0; i < n; i ++)
//    cin >> a[i];
//  cin >> k;
//  cout << solve() << endl;
//  return 0;
//}


#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <bitset>
#include <set>
#include <map>

using namespace std;

#define MAXN 100005
long long a[MAXN];
int n, len, k;
typedef pair<long long, int> PI;
typedef map<PI, bool> MC;
MC m;

long long myabs(long long num)
{
  if (num<0LL) return -num;
  return num;
}

long long solve()
{
  m.clear();
  long long curr = 0;
  for(int i = 0; i < len; i ++)
  {
    curr += a[i];
    m[make_pair(a[i], i)] = true;
  }
  long long ans = myabs(curr);
  for(int i = len; i <= n; i ++)
  {
    if (curr>=0)
    {
      long long tmp = curr;
      int k0=k;
      for(MC::iterator it = m.begin(); it != m.end() && k0>0; it++)
      {
        if (it->first.first>=0) break;
        tmp = tmp - 2LL*(it->first.first);
        k0--;
      }
      ans = max(ans, myabs(tmp));
    }
    if (curr<=0)
    {
      long long tmp = curr;
      int k0=k;
      for(MC::reverse_iterator it = m.rbegin(); it != m.rend() && k0>0; it++)
      {
        if(it->first.first<=0) break;
        tmp = tmp - 2LL*(it->first.first);
        k0--;
      }
      ans = max(ans, myabs(tmp));
    }
    if (i==n) break;
    m.erase(make_pair(a[i-len],i-len));
    m[make_pair(a[i], i)] = true;
    curr -= a[i-len];
    curr += a[i];
  }
  return ans;
}

int main()
{
  //freopen("input.txt","r",stdin);
  cin >> n >> len;
  for(int i = 0; i < n; i ++)
    cin >> a[i];
  cin >> k;
  cout << solve() << endl;
  return 0;
}


#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cctype>

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <list>
#include <iterator>
#include <functional>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;

int64 labs(int64 a)
{
		return a<0 ? (-a) : a;
}
int64 max(int64 a, int64 b)
{
		return a>b?a:b;
}
int64 min(int64 a, int64 b)
{
		return a<b?a:b;
}

#define mp make_pair
#define pb push_back
#define sqr(x) ((x)*(x))
#define forn(i, n) for(int (i)=0; (i)<(n); (i)++)
#define forr(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define forit(i,c) for((i)=(c).begin(); (i)!=(c).end(); (i)++)
#define all(x) (x).begin(), (x).end()
#define zero(a) memset((a), 0, sizeof(a))
#define sqr(x) ((x)*(x))

typedef vector<int> vint;
typedef vector<bool> vbool;
typedef vector<int64> vint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pii64;

priority_queue<pii, vector<pii>, greater<pii> > q1;
priority_queue<pii> q2;
vint v;
int n, k, len;

set<int> pos;

void Clear(priority_queue<pii, vector<pii>, greater<pii>> & q, int i)
{
	while(!q.empty() && q.top().second <= i)
	{
		q.pop();
	}
}
void Clear(priority_queue<pii, vector<pii>, less<pii>> & q, int i)
{
	while(!q.empty() && q.top().second <= i)
	{
		q.pop();
	}
}

void AddElement(int i, int64 & sum)
{
	int j = i - len;
	sum += v[i];
	if (v[i] < 0)
	{
		q1.push(mp(v[i], i));
	}

	Clear(q1, j);
	Clear(q2, j);

	while(pos.size() < k && !q1.empty())
	{
		pos.insert(q1.top().second);
		sum += (int64)2*(-q1.top().first);
		q2.push(q1.top());
		q1.pop();
		Clear(q1, j);
	}

	while(k!=0 && !q1.empty() && q1.top().first < q2.top().first)
	{
		pos.erase(q2.top().second);
		sum -= (int64)2*(-q2.top().first);
		q1.push(q2.top());
		q2.pop();
		Clear(q2, j);

		pos.insert(q1.top().second);
		sum += (int64)2*(-q1.top().first);
		q2.push(q1.top());
		q1.pop();

		Clear(q1, j);
	}
}
void RemoveElement(int i, int64 & sum)
{
	int j = i - len;
	if (pos.count(j))
	{
		sum -= -(int64)v[j];
		pos.erase(j);
	}
	else
	{
		sum -= (int64)v[j];
	}
}

int64 Solve()
{
	Clear(q1, v.size());
	Clear(q2, v.size());
	pos.clear();

	int64 sum = 0;
	int64 res = 0;
	forn(i, len)
	{
		AddElement(i, sum);
		res = max(res, labs(sum));
	}

	for(int i = len; i < n; i++)
	{
		RemoveElement(i, sum);
		AddElement(i, sum);
		res = max(res, labs(sum));
	}
	return res;
}

int main()
{
	//freopen("input.txt", "r", stdin);

	cin >> n >> len;
	v.resize(n);
	forn(i, n)
	{
		cin >> v[i];
	}
	cin >> k;

	int64 res = Solve();
	forn(i, n)
	{
		v[i] *= -1;
	}

	res = max(res, Solve());
	cout << res << endl;

	return 0;
}
/*

*/


#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cmath>
#include <cctype>

#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <list>
#include <iterator>
#include <functional>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;

int64 labs(int64 a)
{
		return a<0 ? (-a) : a;
}
int64 max(int64 a, int64 b)
{
		return a>b?a:b;
}
int64 min(int64 a, int64 b)
{
		return a<b?a:b;
}

#define mp make_pair
#define pb push_back
#define sqr(x) ((x)*(x))
#define forn(i, n) for(int (i)=0; (i)<(n); (i)++)
#define forr(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define forit(i,c) for((i)=(c).begin(); (i)!=(c).end(); (i)++)
#define all(x) (x).begin(), (x).end()
#define zero(a) memset((a), 0, sizeof(a))
#define sqr(x) ((x)*(x))

typedef vector<int> vint;
typedef vector<bool> vbool;
typedef vector<int64> vint64;
typedef pair<int, int> pii;
typedef pair<int64, int64> pii64;

priority_queue<pii, vector<pii>, greater<pii> > q1;
priority_queue<pii> q2;
vint v;
int n, k, len;

set<int> pos;

void Clear(priority_queue<pii, vector<pii>, greater<pii>> & q, int i)
{
	while(!q.empty() && q.top().second <= i)
	{
		q.pop();
	}
}
void Clear(priority_queue<pii, vector<pii>, less<pii>> & q, int i)
{
	while(!q.empty() && q.top().second <= i)
	{
		q.pop();
	}
}

void AddElement(int i, int64 & sum)
{
	int j = i - len;
	sum += v[i];
	if (v[i] < 0)
	{
		q1.push(mp(v[i], i));
	}

	Clear(q1, j);
	Clear(q2, j);

	while(pos.size() < k && !q1.empty())
	{
		pos.insert(q1.top().second);
		sum += (int64)2*(-q1.top().first);
		q2.push(q1.top());
		q1.pop();
		Clear(q1, j);
	}

	while(k!=0 && !q1.empty() && q1.top().first < q2.top().first)
	{
		pos.erase(q2.top().second);
		sum -= (int64)2*(-q2.top().first);
		q1.push(q2.top());
		q2.pop();
		Clear(q2, j);

		pos.insert(q1.top().second);
		sum += (int64)2*(-q1.top().first);
		q2.push(q1.top());
		q1.pop();

		Clear(q1, j);
	}
}
void RemoveElement(int i, int64 & sum)
{
	int j = i - len;
	if (pos.count(j))
	{
		sum -= -(int64)v[j];
		pos.erase(j);
	}
	else
	{
		sum -= (int64)v[j];
	}
}

int64 Solve()
{
	Clear(q1, v.size());
	Clear(q2, v.size());
	pos.clear();

	int64 sum = 0;
	forn(i, len)
	{
		AddElement(i, sum);
	}

	int64 res = labs(sum);

	for(int i = len; i < n; i++)
	{
		RemoveElement(i, sum);
		AddElement(i, sum);
		res = max(res, labs(sum));
	}
	return res;
}

int main()
{
	//freopen("input.txt", "r", stdin);

	cin >> n >> len;
	v.resize(n);
	forn(i, n)
	{
		cin >> v[i];
	}
	cin >> k;

	int64 res = Solve();
	forn(i, n)
	{
		v[i] *= -1;
	}

	res = max(res, Solve());
	cout << res << endl;

	return 0;
}
/*

*/