#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()
#define tc int t;scanf("%d",&t);while (t--0)
typedef long long ll;
const ll MOD=1e9+7;
ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}
ll invmod(ll x) {return power(x,MOD-2);}

ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll min(int a,int b)
{
    if(a>b)
        return b;
    else
        return a;
}
int main()
{
   int n,k;
   cin>>n>>k;
   ll a[n+1],t[n+1];
   for(int i=0;i<n;i++)
   {
    cin>>a[i];
   }
   for(int i=0;i<n;i++)
   {
    cin>>t[i];
   }
   for(int i=1;i<n;i++)
   {
    t[i]+=t[i-1];
   }
   for(int i=1;i<n;i++)
   {
    a[i]+=a[i-1];
   }
   int mx=0;
   int count;
   for(int i=0;i<n;i++)
   {
        if(i==0)
        {
            int p=min(n-1,k+t[k-1]-1);
            count=a[p];
            mx=max(count,mx);
        }
        else
        {
            int p=min(n-1,i+k+t[k-1]-t[i-1]-1);
            count=a[p]-a[i-1];
            mx=max(count,mx);
        }
   }
   cout<<mx<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()
#define tc int t;scanf("%d",&t);while (t--0)
typedef long long ll;
const ll MOD=1e9+7;
ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}
ll invmod(ll x) {return power(x,MOD-2);}

ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll min(int a,int b)
{
    if(a>b)
        return b;
    else
        return a;
}
int main()
{
   int n,k;
   cin>>n>>k;
   ll a[n+1],t[n+1];
   for(int i=0;i<n;i++)
   {
    cin>>a[i];
   }
   for(int i=0;i<n;i++)
   {
    cin>>t[i];
   }
   for(int i=1;i<n;i++)
   {
    t[i]+=t[i-1];
   }
   for(int i=1;i<n;i++)
   {
    a[i]+=a[i-1];
   }
   long long mx=0;
   long long count;
   for(int i=0;i<n;i++)
   {
        if(i==0)
        {
            int p=min(n-1,k+t[k-1]-1);
            count=a[p];
            mx=max(count,mx);
        }
        else
        {
            int p=min(n-1,i+k+t[i+k-1]-t[i-1]-1);
            count=a[p]-a[i-1];
            mx=max(count,mx);
        }
   }
   cout<<mx<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()
#define tc int t;scanf("%d",&t);while (t--0)
typedef long long ll;
const ll MOD=1e9+7;
ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}
ll invmod(ll x) {return power(x,MOD-2);}

ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll min(int a,int b)
{
    if(a>b)
        return b;
    else
        return a;
}
int main()
{
   int n,k;
   cin>>n>>k;
   ll a[n+1],t[n+1],p[n+1];
   for(int i=0;i<n;i++)
   {
    cin>>a[i];
   }
   for(int i=0;i<n;i++)
   {
    cin>>p[i];
   }
   t[0]=p[0];
   for(int i=1;i<n;i++)
   {
    t[i]=t[i-1]+p[i];
   }
   for(int i=1;i<n;i++)
   {
    a[i]+=a[i-1];
   }
   long long mx=0;
   long long count;
   for(int i=0;i<n;i++)
   {
        if(i==0&&p[i]==0)
        {
            int pp=min(n-1,k+t[k-1]-1);
            count=a[pp];
            mx=max(count,mx);
        }
        else if(p[i]==0)
        {
            int pp=min(n-1,i+k+(t[min(n-1,i+k)]-t[i-1])-1);
           // cout<<pp<<endl;
            count=a[pp]-a[i-1];
            mx=max(count,mx);
        }
   }
   cout<<mx<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()
#define tc int t;scanf("%d",&t);while (t--0)
typedef long long ll;
const ll MOD=1e9+7;
ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}
ll invmod(ll x) {return power(x,MOD-2);}

ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll min(int a,int b)
{
    if(a>b)
        return b;
    else
        return a;
}
int main()
{
   int n,k;
   cin>>n>>k;
   ll a[n+1],t[n+1],p[n+1];
   for(int i=0;i<n;i++)
   {
    cin>>a[i];
   }
   for(int i=0;i<n;i++)
   {
    cin>>p[i];
   }
   t[0]=p[0];
   for(int i=1;i<n;i++)
   {
    t[i]=t[i-1]+p[i];
   }
   for(int i=1;i<n;i++)
   {
    a[i]+=a[i-1];
   }
   long long mx=0;
   long long count;
   for(int i=0;i<n;i++)
   {
        if(i==0&&p[i]==0)
        {
            int pp=min(n-1,k+t[k-1]-1);
            count=a[pp];
            mx=max(count,mx);
        }
        else if(p[i]==0)
        {
            int pp=min(n-1,i+k+(t[min(n-1,i+k-1)]-t[i-1])-1);
           // cout<<pp<<endl;
            count=a[pp]-a[i-1];
            mx=max(count,mx);
        }
   }
   cout<<mx<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()
#define tc int t;scanf("%d",&t);while (t--0)
typedef long long ll;
const ll MOD=1e9+7;
ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}
ll invmod(ll x) {return power(x,MOD-2);}

ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll min(int a,int b)
{
    if(a>b)
        return b;
    else
        return a;
}
int main()
{
   int n,k;
   cin>>n>>k;
   ll a[n+1],t[n+1],p[n+1];
   for(int i=0;i<n;i++)
   {
    cin>>a[i];
   }
   for(int i=0;i<n;i++)
   {
    cin>>p[i];
   }
   t[0]=p[0];
   for(int i=1;i<n;i++)
   {
    t[i]+=t[i-1];
   }
   for(int i=1;i<n;i++)
   {
    a[i]+=a[i-1];
   }
   long long mx=0;
   long long count;
   for(int i=0;i<n-k;i++)
   {
        if(i==0&&p[i]==0)
        {
            int p=min(n-1,k+t[k-1]-1);
            count=a[p];
            mx=max(count,mx);
        }
        else if(p[i]==0)
        {
            int p=min(n-1,i+k+t[min(n-1,i+k-1)]-t[i-1]-1);
            count=a[p]-a[i-1];
            mx=max(count,mx);
        }
   }
   cout<<mx<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()
#define tc int t;scanf("%d",&t);while (t--0)
typedef long long ll;
const ll MOD=1e9+7;
ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}
ll invmod(ll x) {return power(x,MOD-2);}

ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll min(int a,int b)
{
    if(a>b)
        return b;
    else
        return a;
}
int main()
{
   int n,k;
   cin>>n>>k;
   ll a[n+1],t[n+1];
   for(int i=0;i<n;i++)
   {
    cin>>a[i];
   }
   for(int i=0;i<n;i++)
   {
    cin>>t[i];
   }
   for(int i=1;i<n;i++)
   {
    t[i]+=t[i-1];
   }
   for(int i=1;i<n;i++)
   {
    a[i]+=a[i-1];
   }
   long long mx=0;
   long long count;
   for(int i=0;i<n;i++)
   {
        if(i==0)
        {
            int p=min(n-1,k+t[k-1]-1);
            count=a[p];
            mx=max(count,mx);
        }
        else
        {
            int p=min(n-1,i+k+t[k-1]-t[i-1]-1);
            count=a[p]-a[i-1];
            mx=max(count,mx);
        }
   }
   cout<<mx<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()
#define tc int t;scanf("%d",&t);while (t--0)
typedef long long ll;
const ll MOD=1e9+7;
ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}
ll invmod(ll x) {return power(x,MOD-2);}

ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll min(int a,int b)
{
    if(a>b)
        return b;
    else
        return a;
}
int main()
{
   int n,k;
   cin>>n>>k;
   ll ans=0;
   ll a[n+1],p[n+1];
   for(int i=0;i<n;i++)
   {
    cin>>a[i];
   }
   for(int i=0;i<n;i++)
   {
    cin>>p[i];
    if(p[i])
        ans+=a[i];
   }

   long long mx=0;
   long long count=0;
   for(int i=0;i<k;i++)
   {
        if(!p[i])
            count+=a[i];
   }
   mx=max(mx,count+ans);
   for(int i=k;i<n;i++)
   {
        if(!p[i-k])
        {
            count-=a[i-k];
        }
        if(!p[i])
        {
            count+=a[i];
        }
        mx=max(mx,ans+count);
   }
   cout<<mx<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define all(a) a.begin(),a.end()
#define tc int t;scanf("%d",&t);while (t--0)
typedef long long ll;
const ll MOD=1e9+7;
ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}
ll invmod(ll x) {return power(x,MOD-2);}

ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll min(int a,int b)
{
    if(a>b)
        return b;
    else
        return a;
}
int main()
{
   int n,k;
   cin>>n>>k;
   ll a[n+1],t[n+1],p[n+1];
   for(int i=0;i<n;i++)
   {
    cin>>a[i];
   }
   for(int i=0;i<n;i++)
   {
    cin>>p[i];
   }
   t[0]=p[0];
   for(int i=1;i<n;i++)
   {
    t[i]=p[i]+p[i-1];
   }
   for(int i=1;i<n;i++)
   {
    a[i]+=a[i-1];
   }
   long long mx=0;
   long long count;
   for(int i=0;i<=n-k;i++)
   {
        if(i==0&&p[i]==0)
        {
            int p=min(n-1,k+t[k-1]-1);
            count=a[p];
            mx=max(count,mx);
        }
        else if(p[i]==0)
        {
            int p=min(n-1,i+k+t[min(n-1,i+k-1)]-t[i-1]-1);
            count=a[p]-a[i-1];
            mx=max(count,mx);
        }
   }
   cout<<mx<<endl;

}


#include <bits/stdc++.h>
/*_*/
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define write  ofstream file_out ; file_out.open("output.txt");
#define read  ifstream file_in ; file_in.open("input.txt");
#define all(x) x.begin(),x.end()
#define ll_str(x,y) stringstream sdf;sdf<<x;string str=sdf.str();y=str;
#define str_ll(x,y) stringstream sstr(x);ll val;sstr>>val;y=val;
#define szz(x)  x.size()
#define endl '\n'
ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }
ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
using namespace std;

int main()
{fast write read

    ll n , k , ans = 0 , mx = LLONG_MIN , s = 0 , y ,sum = 0 , kk = 0 , left , right;
    cin >> n >> k ;
    left =  0 ;
    right = k ;

    vector < pair < ll , bool > > v(n);

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].first;
    }

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].second;
        if(v[i].second)ans+=v[i].first;
        if(i<k&&!v[i].second)kk+=v[i].first;
    }

    for(int i = 0 , ii = k; ii < n ;i++,ii++){
        mx = max(mx,kk);
        if(!v[i].second){kk-=v[i].first;}
        if(!v[ii].second){kk+=v[ii].first;}
        mx = max(mx,kk);
    }

    ans+=mx;
     cout << ans << endl;
}


#include <bits/stdc++.h>
/*_*/
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define write  ofstream file_out ; file_out.open("output.txt");
#define read  ifstream file_in ; file_in.open("input.txt");
#define all(x) x.begin(),x.end()
#define ll_str(x,y) stringstream sdf;sdf<<x;string str=sdf.str();y=str;
#define str_ll(x,y) stringstream sstr(x);ll val;sstr>>val;y=val;
#define szz(x)  x.size()
#define endl '\n'
ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }
ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
using namespace std;

int main()
{fast write read

    ll n , k , ans = 0 , mx = LLONG_MIN , s = 0 , y ,sum = 0 , kk = 0 , left , right;
    cin >> n >> k ;
    left =  0 ;
    right = k ;

    vector < pair < ll , bool > > v(n);

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].first;
        sum += v[i].first;
    }

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].second;
        if(v[i].second)ans+=v[i].first;
    }

    for(int i = 0 ; i <= n-k ;i++){
        if(i<k&&!v[i].second)kk+=v[i].first;
        else {
            mx = max(mx,kk);
            if(!v[left].second){kk-=v[left].first;}
            if(!v[right].second){kk+=v[right].first;}
            left++;
            right++;
            cout << left << " " << right << endl;
        }
    }

    ans+=mx;
    if(n==k)cout << sum <<endl;
    else cout << ans << endl;
}


#include <bits/stdc++.h>
/*_*/
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define write  ofstream file_out ; file_out.open("output.txt");
#define read  ifstream file_in ; file_in.open("input.txt");
#define all(x) x.begin(),x.end()
#define ll_str(x,y) stringstream sdf;sdf<<x;string str=sdf.str();y=str;
#define str_ll(x,y) stringstream sstr(x);ll val;sstr>>val;y=val;
#define szz(x)  x.size()
#define endl '\n'
ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }
ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
using namespace std;

int main()
{fast write read

    ll n , k , ans = 0 , mx = LLONG_MIN , s = 0 , y ,sum = 0 , kk = 0 , left , right;
    cin >> n >> k ;
    left =  0 ;
    right = k ;

    vector < pair < ll , bool > > v(n);

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].first;
        sum += v[i].first;
    }

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].second;
        if(v[i].second)ans+=v[i].first;
        if(i<k&&!v[i].second)kk+=v[i].first;
    }

    for(int i = 0 , ii = k; ii < n ;i++,ii++){
        mx = max(mx,kk);
        if(!v[i].second){kk-=v[i].first;}
        if(!v[ii].second){kk+=v[ii].first;}
    }

    ans+=mx;
    if(n==k)cout << sum <<endl;
    else cout << ans << endl;
}


#include <bits/stdc++.h>
/*_*/
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define write  ofstream file_out ; file_out.open("output.txt");
#define read  ifstream file_in ; file_in.open("input.txt");
#define all(x) x.begin(),x.end()
#define ll_str(x,y) stringstream sdf;sdf<<x;string str=sdf.str();y=str;
#define str_ll(x,y) stringstream sstr(x);ll val;sstr>>val;y=val;
#define szz(x)  x.size()
#define endl '\n'
ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }
ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
using namespace std;

int main()
{fast write read

    ll n , k , ans = 0 , mx = LLONG_MIN , s = 0 , y;
    cin >> n >> k ;

    vector < pair < ll , bool > > v(n);

    for(int i = 0 ; i  < n ;i++)
        cin >> v[i].first;

    for(int i = 0 ; i  < n ;i++)
        cin >> v[i].second;

    for(int i = 0 ; i <= n-k ;i++){
        if(v[i].second)ans+=v[i].first;
        for(int r = i , y = k ;y--;r++){
            if(!v[r].second)s+=v[r].first;
        }
        mx = max(mx,s);
        s = 0 ;
    }

    ans+=mx;

    cout << ans << endl;

}


#include <bits/stdc++.h>
/*_*/
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define write  ofstream file_out ; file_out.open("output.txt");
#define read  ifstream file_in ; file_in.open("input.txt");
#define all(x) x.begin(),x.end()
#define ll_str(x,y) stringstream sdf;sdf<<x;string str=sdf.str();y=str;
#define str_ll(x,y) stringstream sstr(x);ll val;sstr>>val;y=val;
#define szz(x)  x.size()
#define endl '\n'
ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }
ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
using namespace std;

int main()
{fast write read

    ll n , k , ans = 0 ;
    cin >> n >> k ;

    vector < pair < int , bool > > v(n);
    vector < int > mx(n,0);

    for(int i = 0 ; i  < n ;i++)
        cin >> v[i].first;

    for(int i = 0 ; i  < n ;i++)
        cin >> v[i].second;

    for(int i = 0 ; i <= n-k ;i++){
        int y = k ;
        if(v[i].second)ans+=v[i].first;
        for(int r = i ;y--;r++){
            if(!v[r].second)mx[i]+=v[r].first;
        }
    }

    ans+=*max_element(all(mx));

    cout << ans << endl;

}


#include <bits/stdc++.h>
/*_*/
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define write  ofstream file_out ; file_out.open("output.txt");
#define read  ifstream file_in ; file_in.open("input.txt");
#define all(x) x.begin(),x.end()
#define ll_str(x,y) stringstream sdf;sdf<<x;string str=sdf.str();y=str;
#define str_ll(x,y) stringstream sstr(x);ll val;sstr>>val;y=val;
#define szz(x)  x.size()
#define endl '\n'
ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }
ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
using namespace std;

int main()
{fast write read

    ll n , k , ans = 0 , mx = LLONG_MIN , s = 0 , y ,sum = 0 , kk = 0 , left , right;
    cin >> n >> k ;
    left =  0 ;
    right = k ;

    vector < pair < ll , bool > > v(n+3);

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].first;
        sum += v[i].first;
    }

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].second;
        if(v[i].second)ans+=v[i].first;
    }

    for(int i = 0 ; i <= n;i++){
        if(i<k&&!v[i].second)kk+=v[i].first;
        else {
          //  cout << left << " " << right << endl;
            mx = max(mx,kk);
            if(!v[left].second){kk-=v[left].first;}
            if(!v[right].second){kk+=v[right].first;}
            left++;
            right++;
        }
    }

    ans+=mx;
    if(n==k)cout << sum <<endl;
    else cout << ans << endl;
}


#include <bits/stdc++.h>
/*_*/
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define write  ofstream file_out ; file_out.open("output.txt");
#define read  ifstream file_in ; file_in.open("input.txt");
#define all(x) x.begin(),x.end()
#define ll_str(x,y) stringstream sdf;sdf<<x;string str=sdf.str();y=str;
#define str_ll(x,y) stringstream sstr(x);ll val;sstr>>val;y=val;
#define szz(x)  x.size()
#define endl '\n'
ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }
ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
using namespace std;

int main()
{fast write read

    ll n , k , ans = 0 ;
    cin >> n >> k ;

    vector < pair < ll , bool > > v(n);
    vector < ll > mx(n,0);

    for(int i = 0 ; i  < n ;i++)
        cin >> v[i].first;

    for(int i = 0 ; i  < n ;i++)
        cin >> v[i].second;

    for(int i = 0 ; i <= n-k ;i++){
        int y = k ;
        if(v[i].second)ans+=v[i].first;
        for(int r = i ;y--;r++){
            if(!v[r].second)mx[i]+=v[r].first;
        }
    }

    ans+=*max_element(all(mx));

    cout << ans << endl;

}


#include <bits/stdc++.h>
/*_*/
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define write  ofstream file_out ; file_out.open("output.txt");
#define read  ifstream file_in ; file_in.open("input.txt");
#define all(x) x.begin(),x.end()
#define ll_str(x,y) stringstream sdf;sdf<<x;string str=sdf.str();y=str;
#define str_ll(x,y) stringstream sstr(x);ll val;sstr>>val;y=val;
#define szz(x)  x.size()
#define endl '\n'
ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }
ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
using namespace std;

int main()
{fast write read

    ll n , k , ans = 0 , mx = LLONG_MIN , s = 0 , y ,sum = 0;
    cin >> n >> k ;

    vector < pair < ll , bool > > v(n);

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].first;
        sum += v[i].first;
    }

    for(int i = 0 ; i  < n ;i++)
        cin >> v[i].second;

    for(int i = 0 ; i <= n-k ;i++){
        if(v[i].second)ans+=v[i].first;
        for(int r = i , y = k ;y--;r++){
            if(!v[r].second)s+=v[r].first;
        }
        mx = max(mx,s);
        s = 0 ;
    }

    ans+=mx;

    if(n==k)cout << sum <<endl;
    else cout << ans << endl;
}


#include <bits/stdc++.h>
/*_*/
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define write  ofstream file_out ; file_out.open("output.txt");
#define read  ifstream file_in ; file_in.open("input.txt");
#define all(x) x.begin(),x.end()
#define ll_str(x,y) stringstream sdf;sdf<<x;string str=sdf.str();y=str;
#define str_ll(x,y) stringstream sstr(x);ll val;sstr>>val;y=val;
#define szz(x)  x.size()
#define endl '\n'
ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }
ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
using namespace std;

int main()
{fast write read

    ll n , k , ans = 0 , mx = LLONG_MIN , s = 0 , y ,sum = 0 , kk = 0 , left , right;
    cin >> n >> k ;
    left =  0 ;
    right = k ;

    vector < pair < ll , bool > > v(n);

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].first;
        sum += v[i].first;
    }

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].second;
        if(v[i].second)ans+=v[i].first;
    }

    for(int i = 0 ; i <= n;i++){
        if(i<k&&!v[i].second)kk+=v[i].first;
        else {
          //  cout << left << " " << right << endl;
            mx = max(mx,kk);
            if(!v[left].second){kk-=v[left].first;}
            if(!v[right].second){kk+=v[right].first;}
            left++;
            right++;
        }
    }

    ans+=mx;
    if(n==k)cout << sum <<endl;
    else cout << ans << endl;
}


#include <bits/stdc++.h>
/*_*/
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define write  ofstream file_out ; file_out.open("output.txt");
#define read  ifstream file_in ; file_in.open("input.txt");
#define all(x) x.begin(),x.end()
#define ll_str(x,y) stringstream sdf;sdf<<x;string str=sdf.str();y=str;
#define str_ll(x,y) stringstream sstr(x);ll val;sstr>>val;y=val;
#define szz(x)  x.size()
#define endl '\n'
ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }
ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
using namespace std;

int main()
{fast write read

    ll n , k , ans = 0 , mx = LLONG_MIN , s = 0 , y ,sum = 0;
    cin >> n >> k ;

    vector < pair < ll , bool > > v(n);

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].first;
        sum ++ v[i].first;
    }

    for(int i = 0 ; i  < n ;i++)
        cin >> v[i].second;

    for(int i = 0 ; i <= n-k ;i++){
        if(v[i].second)ans+=v[i].first;
        for(int r = i , y = k ;y--;r++){
            if(!v[r].second)s+=v[r].first;
        }
        mx = max(mx,s);
        s = 0 ;
    }

    ans+=mx;

    if(n==k)cout << sum <<endl;
    else cout << ans << endl;
}


#include <bits/stdc++.h>
/*_*/
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define write  ofstream file_out ; file_out.open("output.txt");
#define read  ifstream file_in ; file_in.open("input.txt");
#define all(x) x.begin(),x.end()
#define ll_str(x,y) stringstream sdf;sdf<<x;string str=sdf.str();y=str;
#define str_ll(x,y) stringstream sstr(x);ll val;sstr>>val;y=val;
#define szz(x)  x.size()
#define endl '\n'
ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }
ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
using namespace std;

int main()
{fast write read

    ll n , k , ans = 0 , mx = LLONG_MIN , s = 0 , y ,sum = 0 , kk = 0 , left , right;
    cin >> n >> k ;
    left =  0 ;
    right = k ;

    vector < pair < ll , bool > > v(n);

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].first;
        sum += v[i].first;
    }

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].second;
        if(v[i].second)ans+=v[i].first;
    }

    for(int i = 0 ; i <= n-k ;i++){
        if(i<k&&!v[i].second)kk+=v[i].first;
        else {
            mx = max(mx,kk);
            if(!v[left].second){kk-=v[left].first;}
            if(!v[right].second){kk+=v[right].first;}
            left++;
            right++;
        }
    }

    ans+=mx;
    if(n==k)cout << sum <<endl;
    else cout << ans << endl;
}


#include <bits/stdc++.h>
/*_*/
typedef long long ll;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define write  ofstream file_out ; file_out.open("output.txt");
#define read  ifstream file_in ; file_in.open("input.txt");
#define all(x) x.begin(),x.end()
#define ll_str(x,y) stringstream sdf;sdf<<x;string str=sdf.str();y=str;
#define str_ll(x,y) stringstream sstr(x);ll val;sstr>>val;y=val;
#define szz(x)  x.size()
#define endl '\n'
ll gcd(ll first, ll second) { return !second ? first : gcd(second, first % second); }
ll lcm(ll first, ll second) { return (first / gcd(first, second)) * second; }
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
using namespace std;

int main()
{fast write read

    ll n , k , ans = 0 , mx = LLONG_MIN , s = 0 , y ,sum = 0 , kk = 0 , left , right;
    cin >> n >> k ;
    left =  0 ;
    right = k ;

    vector < pair < ll , bool > > v(n);

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].first;
        sum += v[i].first;
    }

    for(int i = 0 ; i  < n ;i++){
        cin >> v[i].second;
        if(v[i].second)ans+=v[i].first;
        if(i<k&&!v[i].second)kk+=v[i].first;
    }

    for(int i = 0 , ii = k; ii < n ;i++,ii++){
        mx = max(mx,kk);
        if(!v[i].second){kk-=v[i].first;}
        if(!v[ii].second){kk+=v[ii].first;}
        mx = max(mx,kk);
    }

    ans+=mx;
    if(n==k)cout << sum <<endl;
    else cout << ans << endl;
}


#include<bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)

#define ll long long int

#define fr first
#define se second

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size()

#define pb push_back
#define mp make_pair

#define PI 3.141592653589793238

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

#define max(x,y) x > y ? x : y

//inline bool valid(int x, int y){return x >= 0 && x < n && y >= 0 && y < m;}

const int N = 1e5+10;
int a[N], b[N], n, k, f[N], st;
ll cntr;
bool ok;
int main()
{
  IOS;
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cin >> n >> k;
  for(int i = 1; i <= n; i++) cin >> a[i];
  for(int i = 1; i <= n; i++) {cin >> b[i];if(!ok && !b[i])ok = 1, st = i; if(b[i]) cntr += 1ll*a[i];}
  for(int i = 1; i <= n; i++) f[i] = f[i-1] + (b[i] ? 0 : a[i]);
  ll mx = 0;
  for(int i = st; i+k-1 <= n ; i++){
    ll x = f[i+k-1]-f[i-1];
    mx = max(mx, x);
  }
  cout << cntr + mx << endl;
  /*
    *try tricky test cases:
      -bounds
      -small input (0, 1)
      -big input
      -random tests
  */
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)

#define ll long long int

#define fr first
#define se second

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size()

#define pb push_back
#define mp make_pair

#define PI 3.141592653589793238

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

#define max(x,y) x > y ? x : y

//inline bool valid(int x, int y){return x >= 0 && x < n && y >= 0 && y < m;}

const int N = 1e5+10;
int a[N], b[N], n, k, f[N];
ll cntr;
int main()
{
  IOS;
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cin >> n >> k;
  for(int i = 1; i <= n; i++) cin >> a[i];
  for(int i = 1; i <= n; i++) {cin >> b[i]; if(b[i]) cntr += 1ll*a[i];}
  for(int i = 1; i <= n; i++) f[i] = f[i-1] + (b[i] ? 0 : a[i]);
  ll mx = 0;
  for(int i = n; i-k >= 0 ; i--){
    ll x = f[i]-f[i-k];
    mx = max(mx, x);
  }
  cout << cntr + mx << endl;
  /*
    *try tricky test cases:
      -bounds
      -small input (0, 1)
      -big input
      -random tests
  */
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)

#define ll long long int

#define fr first
#define se second

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size()

#define pb push_back
#define mp make_pair

#define PI 3.141592653589793238

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

int n, k;
vector<int>v, vv;
ll sum, s;
//bool valid(int x, int y){return x >= 0 && x < n && y >= 0 && y < m;}

int main()
{
  IOS;
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin >> n >> k;
  v.resize(n);
  vv.resize(n);
  for(int &i : v) cin >> i;
  for(int &i : vv) cin >> i;
  int id = 0;
  for(int i = 0 ; i < n-k ; i++){
      vector<int>a(v.begin()+i, v.begin()+i+k);
      ll d = accumulate(all(a), 0ll);
      if(d > sum) sum = d, id = i;
  }
  for(int i = 0 ; i < id; i ++) s += (vv[i] == 1 ? v[i] : 0);
  for(int i = id+k ; i < n ; i++) s += (vv[i] == 1 ? v[i] : 0);

  cout << s + sum;
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)

#define ll long long int

#define fr first
#define se second

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size()

#define pb push_back
#define mp make_pair

#define PI 3.141592653589793238

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

int n, k;
vector<int>v, vv;
ll sum, s;
//bool valid(int x, int y){return x >= 0 && x < n && y >= 0 && y < m;}

int main()
{
  IOS;
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin >> n >> k;
  v.resize(n);
  vv.resize(n);
  for(int &i : v) cin >> i;
  for(int &i : vv) cin >> i;
  int id = 0;
  for(int i = 0 ; i <= n-k ; i++){
      vector<int>a(v.begin()+i, v.begin()+i+k);
      ll d = accumulate(all(a), 0ll);
      if(d > sum) sum = d, id = i;
  }
  for(int i = 0 ; i < id; i ++) s += (vv[i] == 1 ? v[i] : 0);
  for(int i = id+k ; i < n ; i++) s += (vv[i] == 1 ? v[i] : 0);

  cout << s + sum;
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)

#define ll long long int

#define fr first
#define se second

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size()

#define pb push_back
#define mp make_pair

#define PI 3.141592653589793238

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

int n, k;
int a[111111], b[111111], id = 0;
ll f[111111];
ll sum, s;
//bool valid(int x, int y){return x >= 0 && x < n && y >= 0 && y < m;}

int main()
{
  IOS;
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin >> n >> k;
  for(int i = 1 ; i <= n; i++) {cin >> a[i]; f[i] = f[i-1] + a[i];}
  for(int i = 1; i <= n ; i++) cin >> b[i];
  for(int i = 1 ; i <= n-k+1; i++) if(f[i+k-1]-f[i-1] > sum) sum = f[i+k-1]-f[i-1], id = i;
  for(int i = 1 ; i < id ; i++) s += (b[i] ? a[i] : 0);
  for(int i = id+k ; i <= n ; i++) s += (b[i] ? a[i] : 0);
  cout << sum + s;
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)

#define ll long long int

#define fr first
#define se second

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size()

#define pb push_back
#define mp make_pair

#define PI 3.141592653589793238

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

#define max(x,y) x > y ? x : y

//inline bool valid(int x, int y){return x >= 0 && x < n && y >= 0 && y < m;}

const int N = 1e5+10;
int a[N], b[N], n, k, f[N], st;
ll cntr;
bool ok;
int main()
{
  IOS;
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cin >> n >> k;
  for(int i = 1; i <= n; i++) cin >> a[i];
  for(int i = 1; i <= n; i++) {cin >> b[i];if(!ok && !b[i])ok = 1, st = i; if(b[i]) cntr += 1ll*a[i];}
  for(int i = 1; i <= n; i++) f[i] = f[i-1] + (b[i] ? 0 : a[i]);
  ll mx = 0;
  for(int i = st; i+k-1 <= n ; i++){
    ll x = abs(f[i+k-1]-f[i-1]);
    mx = max(mx, x);
  }
  cout << cntr + mx << endl;
  /*
    *try tricky test cases:
      -bounds
      -small input (0, 1)
      -big input
      -random tests
  */
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)

#define ll long long int

#define fr first
#define se second

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size()

#define pb push_back
#define mp make_pair

#define PI 3.141592653589793238

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

#define max(x,y) x > y ? x : y

//inline bool valid(int x, int y){return x >= 0 && x < n && y >= 0 && y < m;}

const int N = 1e5+10;
int a[N], b[N], n, k, f[N], st;
ll cntr;
bool ok;
int main()
{
  IOS;
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cin >> n >> k;
  for(int i = 1; i <= n; i++) cin >> a[i];
  for(int i = 1; i <= n; i++) {cin >> b[i];if(!ok && !b[i])ok = 1, st = i; if(b[i]) cntr += 1ll*a[i];}
  for(int i = 1; i <= n; i++) f[i] = f[i-1] + (b[i] ? 0 : a[i]);
  ll mx = 0;
  for(int i = n; i >= st ; i--){
    ll x = f[i]-f[i-k];
    mx = max(mx, x);
  }
  cout << cntr + mx << endl;
  /*
    *try tricky test cases:
      -bounds
      -small input (0, 1)
      -big input
      -random tests
  */
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)

#define ll long long int

#define fr first
#define se second

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size()

#define pb push_back
#define mp make_pair

#define PI 3.141592653589793238

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

int n, k;
int a[111111], b[111111], f[111111], id = 1;
ll sum, s;
//bool valid(int x, int y){return x >= 0 && x < n && y >= 0 && y < m;}

int main()
{
  IOS;
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin >> n >> k;
  for(int i = 1 ; i <= n; i++) {cin >> a[i]; f[i] = f[i-1] + a[i];}
  for(int i = 1; i <= n ; i++) cin >> b[i];
  for(int i = 1 ; i <= n-k+1; i++) if(f[i+k-1]-f[i-1] > sum) sum = f[i+k-1]-f[i-1], id = i;
  for(int i = 1 ; i < id ; i++) s += (b[i] ? a[i] : 0);
  for(int i = id+k+1 ; i <= n ; i++) s += (b[i] ? a[i] : 0);
  cout << sum + s;
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)

#define ll long long int

#define fr first
#define se second

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size()

#define pb push_back
#define mp make_pair

#define PI 3.141592653589793238

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

int n, k;
vector<int>v, vv;
ll sum, s;
//bool valid(int x, int y){return x >= 0 && x < n && y >= 0 && y < m;}

int main()
{
  IOS;
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin >> n >> k;
  v.resize(n);
  vv.resize(n);
  for(int &i : v) cin >> i;
  for(int &i : vv) cin >> i;
  int id = 0;
  for(int i = 0 ; i < n ; i++){
    if(vv[i] == 0 && i < n-k){
      vector<int>a(v.begin()+i, v.begin()+i+k);
      ll d = accumulate(all(a), 0ll);
      if(d > sum) sum = d, id = i;
    }
  }
  for(int i = 0 ; i < id; i ++) s += (vv[i] == 1 ? v[i] : 0);
  for(int i = id+k ; i < n ; i++) s += (vv[i] == 1 ? v[i] : 0);

  cout << s + sum;
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)

#define ll long long int

#define fr first
#define se second

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size()

#define pb push_back
#define mp make_pair

#define PI 3.141592653589793238

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

int n, k;
int a[111111], b[111111], f[111111], id = 1;
ll sum, s;
//bool valid(int x, int y){return x >= 0 && x < n && y >= 0 && y < m;}

int main()
{
  IOS;
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin >> n >> k;
  for(int i = 1 ; i <= n; i++) {cin >> a[i]; f[i] = f[i-1] + a[i];}
  for(int i = 1; i <= n ; i++) cin >> b[i];
  for(int i = 1 ; i <= n-k+1; i++) if(f[i+k-1]-f[i-1] > sum) sum = f[i+k-1]-f[i-1], id = i;
  for(int i = 1 ; i < id ; i++) s += (b[i] ? a[i] : 0);
  for(int i = id+k ; i <= n ; i++) s += (b[i] ? a[i] : 0);
  cout << sum + s;
  return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0), cout.tie(0)

#define ll long long int

#define fr first
#define se second

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(v) v.size()

#define pb push_back
#define mp make_pair

#define PI 3.141592653589793238

ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

int n, k;
vector<int>v, vv;
ll sum, s;
//bool valid(int x, int y){return x >= 0 && x < n && y >= 0 && y < m;}

int main()
{
  IOS;
  //freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
  cin >> n >> k;
  v.resize(n);
  vv.resize(n);
  for(int &i : v) cin >> i;
  for(int &i : vv) cin >> i;
  int id = 0;
  for(int i = 0 ; i < n-k ; i++){
    if(vv[i] == 0){
      vector<int>a(v.begin()+i, v.begin()+i+k);
      ll d = accumulate(all(a), 0ll);
      if(d > sum) sum = d, id = i;
    }
  }
  for(int i = 0 ; i < id; i ++) s += (vv[i] == 1 ? v[i] : 0);
  for(int i = id+k ; i < n ; i++) s += (vv[i] == 1 ? v[i] : 0);

  cout << s + sum;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
typedef long long LL;

#define qmax(a,b) ((a)>(b)?(a):(b))

int n,k;
int a[N],t[N];
LL sum[N],sum1[N],res;

int main() {
	scanf("%d%d",&n,&k);
	res = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d",&a[i]);
		//sum[i] = sum[i-1] + a[i];
	}
	for (int i = 1; i <= n; i++) scanf("%d",&t[i]);
	for (int i = 1; i <= n; i++) {
		if (t[i] == 0) sum1[i] = sum1[i-1] + a[i];
		else sum1[i] = sum1[i-1], res += a[i];
	}
	//printf("%lld %lld\n",sum1[3], sum[3] - sum[2]);
	//LL Res = -922337203685477580LL;
	LL Res = 0;
	//for (int i = 1; i <= n - k + 1; i++) {
	//	if (t[i] == 0) {
			//res = qmax(res, sum1[i] + sum[i+k-1] - sum[i-1]);
	//		int temp = 0;
	//		if (i+k-1 > n) temp = n;
	//		else temp = i+k-1;
	//		res = qmax(res, sum1[i] + sum[temp] - sum[i-1]);
	//	}
	//}
	for (int i = 1; i <= n - k + 1; i++) {
		if (!t[i])Res = max(Res, sum1[i+k-1] - sum1[i-1]);
	}
	printf("%lld\n",res+Res);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
typedef long long LL;

#define qmax(a,b) ((a)>(b)?(a):(b))

int n,k;
int a[N],t[N];
LL sum[N],sum1[N],res;

int main() {
	scanf("%d%d",&n,&k);
	res = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d",&a[i]);
		//sum[i] = sum[i-1] + a[i];
	}
	for (int i = 1; i <= n; i++) scanf("%d",&t[i]);
	for (int i = 1; i <= n; i++) {
		if (t[i] == 0) sum1[i] = sum1[i-1] + a[i];
		else sum1[i] = sum1[i-1], res += a[i];
	}
	//printf("%lld %lld\n",sum1[3], sum[3] - sum[2]);
	//LL Res = -922337203685477580LL;
	LL res = 0;
	//for (int i = 1; i <= n - k + 1; i++) {
	//	if (t[i] == 0) {
			//res = qmax(res, sum1[i] + sum[i+k-1] - sum[i-1]);
	//		int temp = 0;
	//		if (i+k-1 > n) temp = n;
	//		else temp = i+k-1;
	//		res = qmax(res, sum1[i] + sum[temp] - sum[i-1]);
	//	}
	//}
	for (int i = 1; i <= n - k + 1; i++) {
		if (!t[i])Res = max(Res, sum1[i+k-1] - sum1[i-1]);
	}
	printf("%lld\n",res+Res);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
typedef long long LL;

#define qmax(a,b) ((a)>(b)?(a):(b))

int n,k;
int a[N],t[N];
LL sum[N],sum1[N];

int main() {
	scanf("%d%d",&n,&k);
	for (int i = 1; i <= n; i++) {
		scanf("%d",&a[i]);
		sum[i] = sum[i-1] + a[i];
	}
	for (int i = 1; i <= n; i++) scanf("%d",&t[i]);
	for (int i = 1; i <= n; i++) {
		if (t[i] == 0) sum1[i] = sum1[i-1];
		else sum1[i] = sum1[i-1] + a[i];
	}
	//printf("%lld %lld\n",sum1[3], sum[5] - sum[2]);
	LL res = -922337203685477580LL;
	for (int i = 1; i <= n - k + 1; i++) {
		if (t[i] == 0) {
			//res = qmax(res, sum1[i] + sum[i+k-1] - sum[i-1]);
			int temp = 0;
			if (i+k-1 > n) temp = n;
			else temp = i+k-1;
			res = qmax(res, sum1[i] + sum[i+k-1] - sum[i-1]);
		}
	}
	printf("%lld\n",res);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
typedef long long LL;

#define qmax(a,b) ((a)>(b)?(a):(b))

int n,k;
int a[N],t[N];
LL sum[N],sum1[N];

int main() {
	scanf("%d%d",&n,&k);
	for (int i = 1; i <= n; i++) {
		scanf("%d",&a[i]);
		sum[i] = sum[i-1] + a[i];
	}
	for (int i = 1; i <= n; i++) scanf("%d",&t[i]);
	for (int i = 1; i <= n; i++) {
		if (t[i] == 0) sum1[i] = sum1[i-1];
		else sum1[i] = sum1[i-1] + a[i];
	}
	//printf("%lld %lld\n",sum1[3], sum[3] - sum[2]);
	LL res = -922337203685477580LL;
	for (int i = 1; i <= n; i++) {
		if (t[i] == 0) {
			//res = qmax(res, sum1[i] + sum[i+k-1] - sum[i-1]);
			int temp = 0;
			if (i+k-1 > n) temp = n;
			else temp = i+k-1;
			res = qmax(res, sum1[i] + sum[temp] - sum[i-1]);
		}
	}
	printf("%lld\n",res);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
typedef long long LL;

#define qmax(a,b) ((a)>(b)?(a):(b))

int n,k;
int a[N],t[N];
LL sum[N],sum1[N];

int main() {
	scanf("%d%d",&n,&k);
	for (int i = 1; i <= n; i++) {
		scanf("%d",&a[i]);
		sum[i] = sum[i-1] + a[i];
	}
	for (int i = 1; i <= n; i++) scanf("%d",&t[i]);
	for (int i = 1; i <= n; i++) {
		if (t[i] == 0) sum1[i] = sum1[i-1];
		else sum1[i] = sum1[i-1] + a[i];
	}
	//printf("%lld %lld\n",sum1[3], sum[5] - sum[2]);
	LL res = -922337203685477580LL;
	for (int i = 1; i <= n - k + 1; i++) {
		if (t[i] == 0) {
			res = qmax(res, sum1[i] + sum[i+k-1] - sum[i-1]);
		}
	}
	printf("%lld\n",res);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
typedef long long LL;

#define qmax(a,b) ((a)>(b)?(a):(b))

int n,k;
int a[N],t[N];
LL sum[N],sum1[N],res;

int main() {
	scanf("%d%d",&n,&k);
	res = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d",&a[i]);
		//sum[i] = sum[i-1] + a[i];
	}
	sum1[0] = 0;
	for (int i = 1; i <= n; i++) scanf("%d",&t[i]);
	for (int i = 1; i <= n; i++) {
		if (t[i] == 0) sum1[i] = sum1[i-1] + a[i];
		else sum1[i] = sum1[i-1], res += a[i];
	}
	//printf("%lld %lld\n",sum1[3], sum[3] - sum[2]);
	//LL Res = -922337203685477580LL;
	LL Res = 0;
	//for (int i = 1; i <= n - k + 1; i++) {
	//	if (t[i] == 0) {
			//res = qmax(res, sum1[i] + sum[i+k-1] - sum[i-1]);
	//		int temp = 0;
	//		if (i+k-1 > n) temp = n;
	//		else temp = i+k-1;
	//		res = qmax(res, sum1[i] + sum[temp] - sum[i-1]);
	//	}
	//}
	//for (int i = 1; i <= n; i++) printf("%lld ", sum1[i]);
	//printf("%lld %lld\n",res, sum1[3]);
	for (int i = 1; i <= n - k + 1; i++) {
		Res = max(Res, sum1[i+k-1] - sum1[i-1]);
	}
	//cout<<Res<<endl;
	printf("%lld\n",res+Res);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
typedef long long LL;

#define qmax(a,b) ((a)>(b)?(a):(b))

int n,k;
int a[N],t[N];
LL sum[N],sum1[N],res;

int main() {
	scanf("%d%d",&n,&k);
	res = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d",&a[i]);
		//sum[i] = sum[i-1] + a[i];
	}
	for (int i = 1; i <= n; i++) scanf("%d",&t[i]);
	for (int i = 1; i <= n; i++) {
		if (t[i] == 0) sum1[i] = sum1[i-1] + a[i];
		else sum1[i] = sum1[i-1], res += a[i];
	}
	//printf("%lld %lld\n",sum1[3], sum[3] - sum[2]);
	LL Res = -922337203685477580LL;
	//for (int i = 1; i <= n - k + 1; i++) {
	//	if (t[i] == 0) {
			//res = qmax(res, sum1[i] + sum[i+k-1] - sum[i-1]);
	//		int temp = 0;
	//		if (i+k-1 > n) temp = n;
	//		else temp = i+k-1;
	//		res = qmax(res, sum1[i] + sum[temp] - sum[i-1]);
	//	}
	//}
	for (int i = 1; i <= n - k + 1; i++) {
		if (!t[i])Res = max(Res, sum1[i+k-1] - sum1[i-1]);
	}
	printf("%lld\n",res+Res);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000010];
int t[1000010];
/*vector<int> stack;
int fn()
{

       while(a[i]<stack[stack.size()-1])
              stack.pop_back();
}*/
int main()
{
       ll n,k,i,s=0,sum=0,ma=INT_MIN,ma_idx;
       cin>>n>>k;
       for(i=0;i<n;i++)
              cin>>a[i];
       for(i=0;i<n;i++)
              cin>>t[i];
       for(i=0;i<n;i++)
       {
              sum+=a[i]*t[i];
       }
//       cout<<sum<<endl;
       for(i=0;i<k;i++)
       {
              s+=a[i]*(1-t[i]);
       }
       for(i=0;i<n-k;i++)
       {
              s+=a[i+k]*(1-t[i+k]);
              s-=a[i]*(1-t[i]);
              if(s>ma)
              {      ma=s; ma_idx=i;}
       }
//       cout<<ma<<" "<<ma_idx<<endl;
       cout<<sum+ma<<endl;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000010];
int t[1000010];
/*vector<int> stack;
int fn()
{

       while(a[i]<stack[stack.size()-1])
              stack.pop_back();
}*/
int main()
{
       ll n,k,i,s=0,ma=INT_MIN,ma_idx;
       cin>>n>>k;
       for(i=0;i<n;i++)
              cin>>a[i];
       for(i=0;i<n;i++)
              cin>>t[i];
       for(i=0;i<k;i++)
       {
              s+=a[i];
              ma=max(s,ma);
       }
       for(i=k;i<n;i++)
       {
              s+=-a[i-k]+a[i];
              if(s>ma)
              {      ma=s; ma_idx=i;}
       }
//       cout<<ma<<" "<<ma_idx<<endl;
       for(i=0;i<n;i++)
       {
              if(t[i]==1&&(i>ma_idx||i<(ma_idx-k+1)))
                     ma+=a[i];
       }
       cout<<ma<<endl;

}


#include<bits/stdc++.h>
using namespace std;
int a[1000010];
int t[1000010];
/*vector<int> stack;
int fn()
{

       while(a[i]<stack[stack.size()-1])
              stack.pop_back();
}*/
int main()
{
       int n,k,i,sum=0,sum_idx;
       cin>>n>>k;
       for(i=0;i<n;i++)
              cin>>a[i];
       for(i=0;i<n;i++)
              cin>>t[i];
       for(i=0;i<n-2;i++)
       {
              if(a[i]+a[i+1]+a[i+2]>sum)
              {       sum=a[i]+a[i+1]+a[i+2]; sum_idx=i;}
       }
//       cout<<sum<<endl;
//       cout<<sum_idx<<endl;
       for(i=0;i<n;i++)
       {
              if(t[i]==1&&i!=sum_idx&&i!=sum_idx+1&&i!=sum_idx+2)
              {       sum+=a[i];}
       }
       cout<<sum<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000010];
int t[1000010];
/*vector<int> stack;
int fn()
{

       while(a[i]<stack[stack.size()-1])
              stack.pop_back();
}*/
int main()
{
       ll n,k,i,s=0,sum=0,ma=INT_MIN,ma_idx;
       cin>>n>>k;
       for(i=0;i<n;i++)
              cin>>a[i];
       for(i=0;i<n;i++)
       cin>>t[i];
       for(i=0;i<n;i++)
       {
              sum+=a[i]*t[i];
       }
//       cout<<sum<<endl;
       for(i=0;i<k;i++)
       {
              s+=a[i]*(1-t[i]);
       }
       for(i=0;i<n-k;i++)
       {
              s+=a[i+k]*(1-t[i+k])-a[i]*(1-t[i]);
              if(s>ma)
              {      ma=s; ma_idx=i;}
       }
//       cout<<ma<<" "<<ma_idx<<endl;
       cout<<sum+ma<<endl;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000010];
int t[1000010];
/*vector<int> stack;
int fn()
{

       while(a[i]<stack[stack.size()-1])
              stack.pop_back();
}*/
int main()
{
       ll n,k,i,s=0,sum=0,ma,ma_idx;
       cin>>n>>k;
       for(i=0;i<n;i++)
              cin>>a[i];
       for(i=0;i<n;i++)
              cin>>t[i];
       for(i=0;i<n;i++)
       {
              sum+=a[i]*t[i];
       }
//       cout<<sum<<endl;
       for(i=0;i<k;i++)
       {
              s+=a[i]*(1-t[i]);
       }
       ma=s;
       for(i=0;i<n-k;i++)
       {
              s+=a[i+k]*(1-t[i+k]);
              s-=a[i]*(1-t[i]);
              if(s>ma)
              {      ma=s; ma_idx=i;}
       }
//       cout<<ma<<" "<<ma_idx<<endl;
       cout<<sum+ma<<endl;
return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000010];
int t[1000010];
/*vector<int> stack;
int fn()
{

       while(a[i]<stack[stack.size()-1])
              stack.pop_back();
}*/
int main()
{
       ll n,k,i,s=0,ma=INT_MIN,ma_idx;
       cin>>n>>k;
       for(i=0;i<n;i++)
              cin>>a[i];
       for(i=0;i<n;i++)
              cin>>t[i];
//       cout<<sum<<endl;
//       cout<<sum_idx<<endl;
       for(i=0;i<k;i++)
       {
              s+=a[i];
              ma=max(s,ma);
       }
       for(i=k;i<n;i++)
       {
              s+=-a[i-k]+a[i];
              if(s>ma)
              {      ma=s; ma_idx=i-k+1;}
       }
//       cout<<ma<<" "<<ma_idx<<endl;
       for(i=0;i<n;i++)
       {
              if(t[i]==1&&(i<ma_idx||i>(ma_idx+k-1)))
                     ma+=a[i];
       }
       cout<<ma<<endl;

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000010];
int t[1000010];
/*vector<int> stack;
int fn()
{

       while(a[i]<stack[stack.size()-1])
              stack.pop_back();
}*/
int main()
{
       ll n,k,i,sum=0,sum_idx;
       cin>>n>>k;
       for(i=0;i<n;i++)
              cin>>a[i];
       for(i=0;i<n;i++)
              cin>>t[i];
       for(i=0;i<n-2;i++)
       {
              if(a[i]+a[i+1]+a[i+2]>sum)
              {       sum=a[i]+a[i+1]+a[i+2]; sum_idx=i;}
       }
//       cout<<sum<<endl;
//       cout<<sum_idx<<endl;
       for(i=0;i<n;i++)
       {
              if(t[i]==1&&i!=sum_idx&&i!=sum_idx+1&&i!=sum_idx+2)
              {       sum+=a[i];}
       }
       cout<<sum<<endl;

}


#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long int a,b,c[100005],d[100005],e=0,f,g=0;
	cin>>a>>b;
	for(int i=1;i<=a;i++){
		cin>>c[i];
	}
	for(int i=1;i<=a;i++){
		cin>>d[i];
	}
	for(int i=1;i<=a;i++){
		if(d[i]==1){
			e+=c[i];
		}
	}
	f=e;
	e=0;
	for(int i=1;i<=a-b+1;i++){
		for(int j=i;j<=i+b-1;j++){
			if(d[j]==0){
				e+=c[j];
			}
		}
		g=max(g,e);
		e=0;
	}
	cout<<f+g;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int a,b,c[100005],d[100005],e=0,f,g=0;
	cin>>a>>b;
	for(int i=0;i<a;i++){
		cin>>c[i];
	}
	for(int i=0;i<b;i++){
		cin>>d[i];
	}
	for(int i=0;i<a;i++){
		if(d[i]==1){
			e+=c[i];
		}
	}
	f=e;
	for(int i=0;i<=a-b;i++){
		for(int j=i;j<i+b;j++){
			if(d[j]==0){
				e+=c[j];
			}
		}
		g=max(g,e);
		e=f;
	}
	cout<<g;
}


#include <iostream>

using namespace std;

int a[100005];
long long b[100005], s, mx;
bool t;

int main()
{
    int n, k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        cin>>a[i];

    for(int i=0; i<n; i++){
        cin>>t;
        if(t)
            s+=a[i];
        else
            b[i] = a[i];
        if(i)
            b[i]+=b[i-1];
    }

    mx = b[k-1];
    for(int i=1; i<n-k+1; i++)
            mx = max(mx, b[i+k-1] - b[i-1]);

    cout<<s + mx;
    return 0;
}


#include <iostream>

using namespace std;

int a[100005];
long long b[100005], s, mx;
bool t;

int main()
{
    int n, k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        cin>>a[i];

    for(int i=0; i<n; i++){
        cin>>t;
        if(t)
            s+=a[i];
        else
            b[i] = a[i];
        if(i)
            b[i]+=b[i-1];
    }
    mx = b[k-1];
    for(int i=1; i<n-k; i++)
        mx = max(mx, b[i+k] - b[i]);
    cout<<s + mx;
    return 0;
}


#include <iostream>

using namespace std;

int a[100005];
long long b[100005], s, mx;
bool t;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        cin>>a[i];

    for(int i=0; i<n; i++){
        cin>>t;
        if(t)
            s+=a[i];
        else
            b[i] = a[i];
        if(i)
            b[i]+=b[i-1];
    }

    mx = b[k-1];
    for(int i=1; i<n-k+1; i++)
            mx = max(mx, b[i+k-1] - b[i-1]);

    cout<<s + mx;
    return 0;
}


#include <iostream>

using namespace std;

void read(long long &x)
{
    register int c;
    x = 0;
    c = getchar();

    for (; (c>47 && c<58); c=getchar())
        x = x *10 + c - 48;
}

void read(bool &x)
{
    register int c;
    c = getchar();
    x = c - 48;
}

long long a[100005], s, mx;
bool t;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        read(a[i]);

    for(int i=0; i<n; i++){
        read(t);
        if(t)
            s+=a[i],
            a[i] = 0;
        if(i)
            a[i]+=a[i-1];
    }

    mx = a[k-1];
    for(int i=1; i<n-k+1; i++)
            mx = max(mx, a[i+k-1] - a[i-1]);

    cout<<s + mx;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

void read(long long &x)
{
    bool n = false;
    register int c;
    x = 0;
    c = getchar();

    if(c=='-'){
        n = true;
        c = getchar();
    }

    for (; (c>47 && c<58); c=getchar())
        x = x *10 + c - 48;

    if(n)
        x *= -1;
}

long long a[100005], s, mx, t;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        read(a[i]);

    for(int i=0; i<n; i++){
        read(t);
        if(t)
            s+=a[i],
            a[i] = 0;
        if(i)
            a[i]+=a[i-1];
    }

    mx = a[k-1];
    for(int i=1; i<n-k+1; i++)
            mx = max(mx, a[i+k-1] - a[i-1]);

    cout<<s + mx;
    return 0;
}


#include <iostream>

using namespace std;

void read(long long &x)
{
    register int c;
    x = 0;
    c = getchar();

    for (; (c>47 && c<58); c=getchar())
        x = x *10 + c - 48;
}

long long a[100005], s, mx, t;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        read(a[i]);

    for(int i=0; i<n; i++){
        read(t);
        if(t)
            s+=a[i],
            a[i] = 0;
        if(i)
            a[i]+=a[i-1];
    }

    mx = a[k-1];
    for(int i=1; i<n-k+1; i++)
            mx = max(mx, a[i+k-1] - a[i-1]);

    cout<<s + mx;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

void read(long long &x)
{
    register int c;
    x = 0;
    c = getchar();

    for (; (c>47 && c<58); c=getchar())
        x = x *10 + c - 48;
}

long long a[100005], s, mx, t;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        read(a[i]);

    for(int i=0; i<n; i++){
        read(t);
        if(t)
            s+=a[i],
            a[i] = 0;
        if(i)
            a[i]+=a[i-1];
    }

    mx = a[k-1];
    for(int i=1; i<n-k+1; i++)
            mx = max(mx, a[i+k-1] - a[i-1]);

    cout<<s + mx;
    return 0;
}


#include <iostream>

using namespace std;

int a[100005];
bool b[100005];
long long c, t, mx;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

    int n, k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<n; i++){
        cin>>b[i];
        if(b[i]) c+=a[i];
    }
    for(int i=0; i<=n-k; i++){
        t = 0;
        for(int j=0; j<k; j++)
            if(!b[i+j])
                t+=a[i+j];
        if(t>mx)
            mx = t;
    }
    c+=mx;
    cout<<c;
    return 0;
}


#include <iostream>

using namespace std;

long long a[100005], s, mx;
bool t;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        cin>>a[i];

    for(int i=0; i<n; i++){
        cin>>t;
        if(t)
            s+=a[i],
            a[i] = 0;
        if(i)
            a[i]+=a[i-1];
    }

    mx = a[k-1];
    for(int i=1; i<n-k+1; i++)
            mx = max(mx, a[i+k-1] - a[i-1]);

    cout<<s + mx;
    return 0;
}


#include <iostream>

using namespace std;

int a[100005];
bool b[100005];
long long c, t, mx;

int main()
{
    int n, k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        cin>>a[i];
    for(int i=0; i<n; i++){
        cin>>b[i];
        if(b[i]) c+=a[i];
    }
    for(int i=0; i<=n-k; i++){
        t = 0;
        for(int j=0; j<k; j++)
            if(!b[i+j])
                t+=a[i+j];
        if(t>mx)
            mx = t;
    }
    c+=mx;
    cout<<c;
    return 0;
}


#include <iostream>

using namespace std;

int a[100005];
long long b[100005], s, mx;
bool t;

int main()
{
    int n, k;
    cin>>n>>k;
    for(int i=0; i<n; i++)
        cin>>a[i];

    for(int i=0; i<n; i++){
        cin>>t;
        if(t)
            s+=a[i];
        else
            b[i] = a[i];
        if(i)
            b[i]+=b[i-1];
    }
    mx = b[k-1];
    for(int i=1; i<n-k; i++)
        mx = max(mx, b[i+k-1] - b[i-1]);
    cout<<s + mx;
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;

	vector<int> a(n), t(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> t[i];

	int ans = 0;
	for(int i = 0; i < n; i++){
		if(t[i] == 1){
			ans += a[i];
			a[i] = 0;
			t[i] = 0;
		}
	}

	vector<int> sum(n);
	sum[0] = a[0];

	for(int i = 1; i < n; i++) sum[i] = sum[i - 1] + a[i];

	int maximum = 0;
	for(int i = k; i < n; i++){
		if(sum[i] - sum[i - k] > maximum) maximum = sum[i] - sum[i - k] ;
	}

	cout << ans + maximum;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;

	vector<int> a(n), t(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> t[i];

	int ans = 0;
	for(int i = 0; i < n; i++){
		if(t[i] == 1){
			ans += a[i];
			a[i] = 0;
			t[i] = 0;
		}
	}

	vector<int> sum(n);
	sum[0] = a[0];

	for(int i = 1; i < n; i++) sum[i] = sum[i - 1] + a[i];

	int maximum = 0;
	for(int i = 0; i + k - 1 < n; i++){
		if(sum[i + k - 1] - sum[i - 1] > maximum) maximum = sum[i + k - 1] - sum[i - 1];
	}

	cout << ans + maximum;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;

	vector<int> a(n), t(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> t[i];

	int ans = 0;
	for(int i = 0; i < n; i++){
		if(t[i] == 1){
			ans += a[i];
			a[i] = 0;
			t[i] = 0;
		}
	}

	vector<int> sum(n);
	sum[0] = a[0];

	for(int i = 1; i < n; i++) sum[i] = sum[i - 1] + a[i];

	int maximum = 0;
	for(int i = 0; i < n - k + 1; i++){
		if(sum[i + k - 1] - sum[i - 1] > maximum) maximum = sum[i + k - 1] - sum[i - 1];
	}

	cout << ans + maximum;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;

	vector<long long> a(n), t(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> t[i];

	long long ans = 0;
	for(int i = 0; i < n; i++){
		if(t[i] == 1){
			ans += a[i];
			a[i] = 0;
			t[i] = 0;
		}
	}

	vector<long long> sum(n);
	sum[0] = a[0];

	for(int i = 1; i < n; i++) sum[i] = sum[i - 1] + a[i];

	long long maximum = 0;
	for(int i = 0; i < n - k + 1; i++){
		if(sum[i + k - 1] - sum[i - 1] > maximum) maximum = sum[i + k - 1] - sum[i - 1];
	}

	cout << ans + maximum;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;

	vector<long long> a(n), t(n);
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> t[i];

	long long ans = 0;

	vector<long long> sum(n);
	for(int i = 1; i <= n; i++){
		if(t[i] == 1){
			ans += a[i];
			a[i] = 0;
		}
		sum[i] = sum[i - 1] + a[i];
	}

	long long maximum = 0;
	for(int i = 1; i <= n - k + 1; i++){
		if(sum[i + k - 1] - sum[i - 1] > maximum) maximum = sum[i + k - 1] - sum[i - 1];
	}

	cout << ans + maximum;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n, k;
	cin >> n >> k;

	vector<int> a(n), t(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> t[i];

	int ans = 0;
	for(int i = 0; i < n; i++){
		if(t[i] == 1){
			ans += a[i];
			a[i] = 0;
			t[i] = 0;
		}
	}

	vector<int> sum(n);
	sum[0] = a[0];

	for(int i = 1; i < n; i++) sum[i] = sum[i - 1] + a[i];

	int maximum = sum[0];
	for(int i = 1; i + k - 1 < n; i++){
		if(sum[i + k - 1] - sum[i - 1] > maximum) maximum = sum[i + k - 1] - sum[i - 1];
	}

	cout << ans + maximum;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n, k;
	cin >> n >> k;

	vector<long long> a(n + 1), t(n + 1);
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> t[i];

	long long ans = 0;

	vector<long long> sum(n + 1);
	for(int i = 1; i <= n; i++){
		if(t[i] == 1){
			ans += a[i];
			a[i] = 0;
		}
		sum[i] = sum[i - 1] + a[i];
	}

	long long maximum = 0;
	for(int i = 1; i <= n - k + 1; i++){
		if(sum[i + k - 1] - sum[i - 1] > maximum) maximum = sum[i + k - 1] - sum[i - 1];
	}

	cout << ans + maximum;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n, k;
	cin >> n >> k;

	vector<long long> a(n), t(n);
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> t[i];

	long long ans = 0;

	vector<long long> sum(n);
	for(int i = 1; i <= n; i++){
		if(t[i] == 1){
			ans += a[i];
			a[i] = 0;
		}
		sum[i] = sum[i - 1] + a[i];
	}

	long long maximum = 0;
	for(int i = 1; i <= n - k + 1; i++){
		if(sum[i + k - 1] - sum[i - 1] > maximum) maximum = sum[i + k - 1] - sum[i - 1];
	}

	cout << ans + maximum;
}


#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std ;
  int n , s  , k , x[100009] , y[100009] , l , r  , ans  , a ;
int main(){
    cin >> n >> k ;
    for (int i = 0 ; i  < n ; i++) scanf("%d" , &x[i]) ;
    for (int i = 0 ;i  < n ; i++){
      cin >> y[i] ;
      if (y[i])  a += x[i] ;
    }
    while(l < n - k +1  ){
           while ( r < l + k  ) {
             if (!y[l]) a += x[r] ;
             r++ ;
         }
         ans = max (ans , a ) ;
          if (!y[l]) a -= x[l] ;
         l++ ;
         ans = max (ans , a ) ;

    }
     cout << ans ;
}


#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std ;
  int n , s  , k , x[100009] , y[100009] , l , r  , ans  , a ;
int main(){
    cin >> n >> k ;
    for (int i = 0 ; i  < n ; i++) scanf("%d" , &x[i]) ;
    for (int i = 0 ;i  < n ; i++){
      cin >> y[i] ;
      if (y[i])  ans += x[i] ;
    }
    while(l < n - k ){
        s = 0 ;
        r =  l + k - 1 ;
         if (!y[l]){
           while ( l <= r ) {
             if (!y[l]) s += x[l] ;
             l++ ;
           }
         }
         l++ ;
         a = max (a , s ) ;
    }
     cout << ans + a ;
}


#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std ;
  int n , s  , e  , k , x[100009] , y[100009] , z[100009],  l , r , st , ed ;
  ll ans , ans1 , sum , a ;
int main(){
    cin >> n >> k ;
    for (int i = 1 ; i  <= n ; i++) {

      scanf("%d" , &x[i]) ;
      z[i] = x[i] ;
     x[i] += x[i-1] ;
     }
    for (int i = 1 ; i <= n ; i++){
      cin >> y[i] ;
      if ( y[i] )  ans += z[i] ;
    }
          ans1 = ans ;
          l = 1 ;
    while( l <= n ){
        sum = 0 ;
        sum = x[l+k-1] - x[l-1] ;
        for (int i = l ; i <= l + k -1 ; i++) if (y[i]) sum -= z[i] ;
        if (sum > a ){
          a = sum ;
          ed = l + k -1 ;
          st = l ;
        }
         l++ ;
    }

     cout << ans + a  ;
}


#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std ;
  int n , s  , e  , k , x[100009] , y[100009] , l , r ;
  ll ans , ans1 , sum ;
int main(){
    cin >> n >> k ;
    for (int i = 0 ; i  < n ; i++) scanf("%d" , &x[i]) ;
    for (int i = 0 ;i  < n ; i++){
      cin >> y[i] ;
      if ( y[i] )  ans += x[i] ;
    }
          ans1 = ans ;
    while( l < n - k +1  ){
          sum = 0 ;
          for (int i = l ; i < l + k  ; i++) if ( !y[i] ) sum += x[i] ;
          ans = max (ans , ans1 + sum ) ;
          l++ ;

        //  cout << ans << ' ' << l << ' ' << sum << endl ;
    }
     cout << ans  ;
}


#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std ;
  int n , s  , e  , k , x[100009] , y[100009] , l , r  , ans , ans1 , a , sum  ;
int main(){
    cin >> n >> k ;
    for (int i = 0 ; i  < n ; i++) scanf("%d" , &x[i]) ;
    for (int i = 0 ;i  < n ; i++){
      cin >> y[i] ;
      if ( y[i] )  ans += x[i] ;
    }
          ans1 = ans ;
          r = l + k ;
    while( l < n - k  ){
          sum = 0 ;
          for (int i = l ; i < r ; i++) if (!y[i]) sum += x[i] ;
          ans = max (ans , ans1 + sum ) ;
          l++ ;
          r = l + k ;
        //  cout << ans << ' ' << l << ' ' << r << endl ;
    }
     cout << ans  ;
}


#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std ;
  int n , s  , e  , k , x[100009] , y[100009] , z[100009],  l , r , st , ed ;
  ll ans , ans1 , sum , a ;
int main(){
    cin >> n >> k ;
    for (int i = 1 ; i  <= n ; i++) {

      scanf("%d" , &x[i]) ;
      z[i] = x[i] ;
     x[i] += x[i-1] ;
     }
    for (int i = 1 ; i <= n ; i++){
      cin >> y[i] ;
      if ( y[i] )  ans += z[i] ;
    }
          ans1 = ans ;
          l = 1 ;
    while( l <= n ){
      if (!y[l])  sum = 0 ;
          int t = l+k-1 ;
          if (t > n ) t = n
        sum = x[n] - x[l-1] ;
        if (sum > a ){
          a = sum ;
          ed = l + k -1 ;
          st = l ;
        }
         l++ ;
    }
for (int i = st ; i <= ed ; i++) if (y[i]) sum -= z[i] ;

     cout << ans + a  ;
}


#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std ;
  int n , s  , e  , k , x[100009] , y[100009] , l , r ;
  ll ans , ans1 , sum ;
int main(){
    cin >> n >> k ;
    for (int i = 0 ; i  < n ; i++) scanf("%d" , &x[i]) ;
    for (int i = 0 ;i  < n ; i++){
      cin >> y[i] ;
      if ( y[i] )  ans += x[i] ;
    }
          ans1 = ans ;
    while( l < n - k +1  ){
        while (r < l + k ){
              if ( !y[r] ) sum += x[r] ;
                r++ ;
            }
          ans = max (ans , ans1 + sum ) ;
          if (!y[l]) sum-=x[l] ;
          ans = max (ans , ans1 + sum ) ;
          l++ ;

        //  cout << ans << ' ' << l << ' ' << sum << endl ;
    }
     cout << ans  ;
}


#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std ;
  int n , s  , k , x[100009] , y[100009] , l , r  , ans  , a ;
int main(){
    cin >> n >> k ;
    for (int i = 0 ; i  < n ; i++) scanf("%d" , &x[i]) ;
    for (int i = 0 ;i  < n ; i++){
      cin >> y[i] ;
      if (y[i])  ans += x[i] ;
    }
    while(l < n - k ){
        r =  l + k ;
         if (!y[l]){
           while (l < r ) {
             if (!y[l]) s += x[l] ;
             l++ ;
           }
         }
         l++ ;
         a = max (a , s ) ;
    }
     cout << ans + a ;
}


#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std ;
  int n , s  , e  , k , x[100009] , y[100009] , l , r ;
  ll ans , ans1 , sum ;
int main(){
    cin >> n >> k ;
    for (int i = 0 ; i  < n ; i++) scanf("%d" , &x[i]) ;
    for (int i = 0 ;i  < n ; i++){
      cin >> y[i] ;
      if ( y[i] )  ans += x[i] ;
    }
          ans1 = ans ;
    while( l < n - k  ){
          sum = 0 ;
          for (int i = l ; i < l + k  ; i++) if ( !y[i] ) sum += x[i] ;
          ans = max (ans , ans1 + sum ) ;
          l++ ;
        //  cout << ans << ' ' << l << ' ' << r << endl ;
    }
     cout << ans  ;
}


#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std ;
  int n , s  , e  , k , x[100009] , y[100009] , z[100009],  l , r , st , ed ;
  ll ans , ans1 , sum , a ;
int main(){
    cin >> n >> k ;
    for (int i = 1 ; i  <= n ; i++) {

      scanf("%d" , &x[i]) ;
      z[i] = x[i] ;
     x[i] += x[i-1] ;
     }
    for (int i = 1 ; i <= n ; i++){
      cin >> y[i] ;
      if ( y[i] )  ans += z[i] ;
    }
          ans1 = ans ;
          l = 1 ;
    while( l <= n ){
        sum = 0 ;
        sum = x[l+k-1] - x[l-1] ;
        if (sum > a ){
          a = sum ;
          ed = l + k -1 ;
          st = l ;
        }
         l++ ;
    }
for (int i = st ; i <= ed ; i++) if (y[i]) sum -= z[i] ;

     cout << ans + a  ;
}


#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std ;
  int n , s  , e  , k , x[100009] , y[100009] , z[100009],  l , r , st , ed ;
  ll ans , ans1 , sum , a ;
int main(){
    cin >> n >> k ;
    for (int i = 1 ; i  <= n ; i++) {

      scanf("%d" , &x[i]) ;
      z[i] = x[i] ;
     x[i] += x[i-1] ;
     }
    for (int i = 1 ; i <= n ; i++){
      cin >> y[i] ;
      if ( y[i] )  ans += z[i] ;
    }
          ans1 = ans ;
          l = 1 ;
    while( l <= n ){
      if (!y[l])  sum = 0 ;
          int t = l+k-1 ;
          if (t > n ) t = n ;
        sum = x[n] - x[l-1] ;
        if (sum > a ){
          a = sum ;
          ed = l + k -1 ;
          st = l ;
        }
         l++ ;
    }
for (int i = st ; i <= ed ; i++) if (y[i]) sum -= z[i] ;

     cout << ans + a  ;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a1[n],a2[n];
    for(int i=0;i<n;i++){
        cin>>a1[i];
    }
    for(int j=0;j<n;j++){
        cin>>a2[j];
    }
    long long int sum1=0;;
    int a[n-k+1];
    long long int sum;
    long long int s1=0;
    int j=0;
    int x=0;
    while(x<k){
            s1=s1+a1[j];
            //cout<<a1[j]<<"  ";
            j++;
            x++;
        }
    for (int i=0;i<n-k+1;i++){
        //cout<<sum1<<"  "<<s1<<endl;
        sum=sum1+s1;
        a[i]=sum;
        if(a2[i]==1){
            sum1=sum1+a1[i];
        }
        s1=s1-a1[i]+a1[i+k];
    }
    long long int m1=-1000000000;
    for(int i=0;i<n-k+1;i++){
        if(m1<a[i]){
            m1=a[i];
        }
    }
    for(int i=n-k+1;i<n;i++){
        if(m1<a1[i]){
            m1=a[i];
        }
    }
    cout<<m1<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a1[n],a2[n];
    for(int i=0;i<n;i++){
        cin>>a1[i];
    }
    for(int j=0;j<n;j++){
        cin>>a2[j];
    }
    long long int sum1=0;;
    long long int a[n-k+1];
    long long int sum;
    long long int s1=0;
    int j=0;
    int x=0;
    while(x<k){
            s1=s1+a1[j];
            //cout<<a1[j]<<"  ";
            j++;
            x++;
        }
    for (int i=0;i<n-k+1;i++){
        //cout<<sum1<<"  "<<s1<<endl;
        sum=sum1+s1;
        a[i]=sum;
        if(a2[i]==1){
            sum1=sum1+a1[i];
        }
        s1=s1-a1[i]+a1[i+k-1];
    }
    long long int m1=-1000000000;
    for(int i=0;i<n-k+1;i++){
        if(m1<a[i]){
            m1=a[i];
        }
    }
    for(int i=n-k+1;i<n;i++){
        if(m1<a1[i]){
            m1=a1[i];
        }
    }
    cout<<m1<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a1[n],a2[n];
    for(int i=0;i<n;i++){
        cin>>a1[i];
    }
    for(int j=0;j<n;j++){
        cin>>a2[j];
    }
    long long int sum1=0;;
    int a[n-k+1];
    long long int sum;
    long long int s1;
    for (int i=0;i<n-k+1;i++){
        int j=i;
        int x=0;
        s1=0;
        while(x<k){
            s1=s1+a1[j];
            //cout<<a1[j]<<"  ";
            j++;
            x++;
        }
        //cout<<sum1<<"  "<<s1<<endl;
        sum=sum1+s1;
        a[i]=sum;
        if(a2[i]==1){
            sum1=sum1+a1[i];
        }
    }
    long long int m1=-1000000000;
    for(int i=0;i<n-k+1;i++){
        if(m1<a[i]){
            m1=a[i];
        }
    }
    for(int i=n-k+1;i<n;i++){
        if(m1<a1[i]){
            m1=a[i];
        }
    }
    cout<<m1<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a1[n],a2[n];
    for(int i=0;i<n;i++){
        cin>>a1[i];
    }
    for(int j=0;j<n;j++){
        cin>>a2[j];
    }
    long long int sum1=0;;
    int a[n-k+1];
    long long int sum;
    long long int s1=0;
    int j=0;
    int x=0;
    while(x<k){
            s1=s1+a1[j];
            //cout<<a1[j]<<"  ";
            j++;
            x++;
        }
    for (int i=0;i<n-k+1;i++){
        //cout<<sum1<<"  "<<s1<<endl;
        sum=sum1+s1;
        a[i]=sum;
        if(a2[i]==1){
            sum1=sum1+a1[i];
        }
        s1=s1-a1[i]+a1[i+k];
    }
    long long int m1=-1000000000;
    for(int i=0;i<n-k+1;i++){
        if(m1<a[i]){
            m1=a[i];
        }
    }
    for(int i=n-k+1;i<n;i++){
        if(m1<a1[i]){
            m1=a1[i];
        }
    }
    cout<<m1<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a1[n],a2[n];
    for(int i=0;i<n;i++){
        cin>>a1[i];
    }
    for(int j=0;j<n;j++){
        cin>>a2[j];
    }
    long long int sum1=0;;
    long long int a[n-k+1];
    long long int sum;
    long long int s1=0;
    int j=0;
    int x=0;
    while(x<k){
            s1=s1+a1[j];
            //cout<<a1[j]<<"  ";
            j++;
            x++;
        }
    for (int i=0;i<n-k+1;i++){
        //cout<<sum1<<"  "<<s1<<endl;
        sum=sum1+s1;
        a[i]=sum;
        if(a2[i]==1){
            sum1=sum1+a1[i];
        }
        if(i!=n-k)
        s1=s1-a1[i]+a1[i+k];
    }
    long long int m1=-1000000000;
    for(int i=0;i<n-k+1;i++){
        if(m1<a[i]){
            m1=a[i];
        }
    }
    for(int i=n-k+1;i<n;i++){
        if(m1<a1[i]){
            m1=a1[i];
        }
    }
    cout<<m1<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a1[n],a2[n];
    for(int i=0;i<n;i++){
        cin>>a1[i];
    }
    for(int j=0;j<n;j++){
        cin>>a2[j];
    }
    long long int sum1=0;;
    long long int a[n-k+1];
    long long int sum;
    long long int s1=0;
    int j=0;
    int x=0;
    while(x<k){
            s1=s1+a1[j];
            //cout<<a1[j]<<"  ";
            j++;
            x++;
        }
    for (int i=0;i<n-k;i++){
        //cout<<sum1<<"  "<<s1<<endl;
        sum=sum1+s1;
        a[i]=sum;
        if(a2[i]==1){
            sum1=sum1+a1[i];
        }
        s1=s1-a1[i]+a1[i+k];
    }
    long long int m1=-1000000000;
    for(int i=0;i<n-k;i++){
        if(m1<a[i]){
            m1=a[i];
        }
    }
    for(int i=n-k;i<n;i++){
        if(m1<a1[i]){
            m1=a1[i];
        }
    }
    cout<<m1<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a1[n],a2[n];
    for(int i=0;i<n;i++){
        cin>>a1[i];
    }
    for(int j=0;j<n;j++){
        cin>>a2[j];
    }
    long long int sum1=0;;
    long long int a[n-k+1];
    long long int sum;
    long long int s1=0;
    int j=0;
    int x=0;
    int b[n];
    int x1=n-1;
    int send=0;
    while(x1>=0){
        if(a2[x1]==1){
            send=send+a1[x1];
        }
        b[x1]=send;
        x1--;
    }

    while(x<k){
            s1=s1+a1[j];
            //cout<<a1[j]<<"  ";
            j++;
            x++;
        }
    for (int i=0;i<n-k+1;i++){
        //cout<<sum1<<"  "<<s1<<endl;
        sum=sum1+s1+b[i+k-1];
        a[i]=sum;
        if(a2[i]==1){
            sum1=sum1+a1[i];
        }
        if(i!=n-k)
        s1=s1-a1[i]+a1[i+k];
    }

    long long int m1=-1000000000;
    for(int i=0;i<n-k+1;i++){
        if(m1<a[i]){
            m1=a[i];
        }
    }
    for(int i=n-k+1;i<n;i++){
        if(m1<a1[i]){
            m1=a1[i];
        }
    }
    //cout<<endl;
    cout<<m1<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a1[n],a2[n];
    for(int i=0;i<n;i++){
        cin>>a1[i];
    }
    for(int j=0;j<n;j++){
        cin>>a2[j];
    }
    long long int sum1=0;;
    long long int a[n-k+1];
    long long int sum;
    long long int s1=0;
    int j=0;
    int x=0;
    while(x<k){
            s1=s1+a1[j];
            //cout<<a1[j]<<"  ";
            j++;
            x++;
        }
    for (int i=0;i<n-k+1;i++){
        //cout<<sum1<<"  "<<s1<<endl;
        sum=sum1+s1;
        a[i]=sum;
        if(a2[i]==1){
            sum1=sum1+a1[i];
        }
        s1=s1-a1[i]+a1[i+k];
    }
    long long int m1=-1000000000;
    for(int i=0;i<n-k+1;i++){
        if(m1<a[i]){
            m1=a[i];
        }
    }
    for(int i=n-k+1;i<n;i++){
        if(m1<a1[i]){
            m1=a1[i];
        }
    }
    cout<<m1<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a1[n],a2[n];
    for(int i=0;i<n;i++){
        cin>>a1[i];
    }
    for(int j=0;j<n;j++){
        cin>>a2[j];
    }
    long long int sum1=0;;
    long long int a[n-k+1];
    long long int sum;
    long long int s1=0;
    int j=0;
    int x=0;
    while(x<k){
            s1=s1+a1[j];
            //cout<<a1[j]<<"  ";
            j++;
            x++;
        }
    for (int i=0;i<n-k;i++){
        //cout<<sum1<<"  "<<s1<<endl;
        sum=sum1+s1;
        a[i]=sum;
        if(a2[i]==1){
            sum1=sum1+a1[i];
        }
        s1=s1-a1[i]+a1[i+k];
    }
    long long int m1=-1000000000;
    for(int i=0;i<n-k+1;i++){
        if(m1<a[i]){
            m1=a[i];
        }
    }
    for(int i=n-k+1;i<n;i++){
        if(m1<a1[i]){
            m1=a1[i];
        }
    }
    cout<<m1<<endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a1[n],a2[n];
    for(int i=0;i<n;i++){
        cin>>a1[i];
    }
    for(int j=0;j<n;j++){
        cin>>a2[j];
    }
    long long int sum1=0;;
    long long int a[n-k+1];
    long long int sum;
    long long int s1=0;
    int j=0;
    int x=0;
    int b[n];
    int x1=n-1;
    int send=0;
    while(x1>=0){
        if(a2[x1]==1){
            send=send+a1[x1];
        }
        b[x1]=send;
        x1--;
    }

    while(x<k){
            s1=s1+a1[j];
            //cout<<a1[j]<<"  ";
            j++;
            x++;
        }
    for (int i=0;i<n-k+1;i++){
        //cout<<sum1<<"  "<<s1<<endl;
        if(i!=n-k)
        sum=sum1+s1+b[i+k];
        else
        sum=s1+sum1;
        a[i]=sum;
        if(a2[i]==1){
            sum1=sum1+a1[i];
        }
        if(i!=n-k)
        s1=s1-a1[i]+a1[i+k];
    }

    long long int m1=-1000000000;
    for(int i=0;i<n-k+1;i++){
        if(m1<a[i]){
            m1=a[i];
        }
    }
    for(int i=n-k+1;i<n;i++){
        if(m1<a1[i]){
            m1=a1[i];
        }
    }
    //cout<<endl;
    cout<<m1<<endl;
}


#define _CRT_SECURE_NO_DEPRECATE
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <bitset>
#include <cmath>
#include <ctime>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <sstream>
using namespace std;

struct point
{
	int x;
	int number;
public: point()
{
	;
}
public: point(int a, int b)
{
	x = a;
	number = b;
}
};
const bool operator<(const point &a, const point &b)
{
	return a.x < b.x;
}
const bool comp2(const point &a, const point &b)
{
	return a.x > b.x;
}

int main()
{
	int n;
	cin >> n;
	vector<int>a(n);
	for (int &i : a)
	{
		cin >> i;
	}
	set<point>s1;
	set<point>s2;
	s1.insert(point(a[0],1));
	for (int i = 2; i < n; i++)
	{
		s2.insert(point(a[i], i + 1));
	}
	for (int i = 1; i < n - 1; i++)
	{
		point temp = point(a[i], i + 1);
		auto tempiter = s2.find(temp);
		if (tempiter!=s2.end())
		{
			s2.erase(tempiter);
		}
		tempiter = s1.upper_bound(temp);
		auto tempiter2 = s2.upper_bound(temp);
		/*for (point j : s1)
		{
			cout << j.number << " ";
		}
		cout << endl;
		for (pair<int, int> j : s2)
		{
			cout << j.second << " ";
		}
		cout << endl;*/
		if (tempiter != s1.end() && tempiter2 != s2.end())
		{
			cout << "3" << endl << tempiter->number << " " << (i + 1) << " " << tempiter2->number;
			return 0;
		}
		s1.insert(temp);
	}
	s1.clear();
	s2.clear();
	s1.insert(point(-a[0], 1));
	for (int i = 2; i < n; i++)
	{
		s2.insert(point(-a[i], i + 1));
	}
	for (int i = 1; i < n - 1; i++)
	{
		point temp = point(-a[i], i + 1);
		auto tempiter = s2.find(temp);
		if (tempiter != s2.end())
		{
			s2.erase(tempiter);
		}
		tempiter = s1.upper_bound(temp);
		auto tempiter2 = s2.upper_bound(temp);
		if (tempiter != s1.end() && tempiter2 != s2.end())
		{
			cout << "3" << endl << tempiter->number << " " << (i + 1) << " " << tempiter2->number;
			return 0;
		}
		s1.insert(temp);
	}
	cout << "0";
	return 0;
}


#include<iostream>
using namespace std;
int v[100005];
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>v[i];
        if(n<3)
        {
            cout<<0;
            return 0;
        }
     for(int i=1;i<n;i++)
    {
        if(v[i]>v[i+1])
        {
            for(int j=i+1;j<=n;++j)
                if(v[j]<v[j+1])
                {
                    cout<<3<<endl<<i<<" "<<j<<" "<<j+1;
                    return 0;
                }
        }
        if(v[i]<a[i+1])
        {
            for(int j=i+1;j<=n;++j)
                if(v[j]>v[j+1])
                {
                    cout<<3<<endl<<i<<" "<<j<<" "<<j+1;
                    return 0;
                }
        }
    }
    cout<<0;
    return 0;
}


#include<iostream>
using namespace std;
int v[100005],dr[100005],st[100005];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)
        cin>>v[i];
    for(int i=1;i<=n;++i)
        for(int j=1;j<i;++j)
        {
        if(v[j]<v[i])
        {
            st[i]=j;
            break;
        }
        }
    for(int i=1;i<=n;++i)
        for(int j=n;j>i;--j)
            if(v[j]<v[i])
            {
                dr[i]=j;
                break;
            }
    for(int i=1;i<=n;++i)
        if(dr[i] && st[i])
        {
            cout<<3<<endl<<st[i]<<" "<<i<<" "<<dr[i];
            return 0;
        }
    cout<<0;
}


#include<iostream>
using namespace std;
int v[100005];
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>v[i];
        if(n<3)
        {
            cout<<0;
            return 0;
        }
     for(int i=1;i<n;i++)
    {
        if(v[i]>v[i+1])
        {
            for(int j=i;j<=n;++j)
                if(v[j]<v[j+1])
                {
                    cout<<3<<endl<<i<<" "<<j<<" "<<j+1;
                    return 0;
                }
        }
        if(v[i]<a[i+1])
        {
            for(int j=i;j<=n;++j)
                if(v[j]>v[j+1])
                {
                    cout<<3<<endl<<i<<" "<<j<<" "<<j+1;
                    return 0;
                }
        }
    }
    cout<<0;
    return 0;
}


#include<iostream>
using namespace std;
int v[100005];
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>v[i];
        if(n<3)
        {
            cout<<0;
            return 0;
        }
     for(int i=1;i<n;i++)
    {
        if(v[i]>v[i+1])
        {
            for(int j=i+1;j<n;++j)
                if(v[j]<v[j+1])
                {
                    cout<<3<<endl<<i<<" "<<j<<" "<<j+1;
                    return 0;
                }
        }
        if(v[i]<v[i+1])
        {
            for(int j=i+1;j<n;++j)
                if(v[j]>v[j+1])
                {
                    cout<<3<<endl<<i<<" "<<j<<" "<<j+1;
                    return 0;
                }
        }
    }
    cout<<0;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long int ll;
typedef long long int lli;
typedef double db;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define sz(a) ll((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())             // for sets,maps etc O(log(n));
#define cpresent(c,x) (find(all(c),x) != (c).end())         // for vector and others O(n);
#define rep(i,a,b) for( int i = a; i < b; i++)
#define _USE_MATH_DEFINES
#define M 100000007

ll arr[100001];
ll s[1000010];
ll l[1000010];
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    rep(i,0,n){
        cin>>arr[i];
    }
    // vi v(arr, arr+n);
    // cout<<" vector ";tr(v, itr) cout<<*itr<<" ";cout<<endl;
    // sort(all(v));
    // tr(v, itr){
    //     ll num = *itr;
    //     ll sm = lower_bound(all(v), num) - v.begin();
    //     ll lr = v.end() - upper_bound(all(v), num) ;
    //     s[num] = sm;
    //     l[num]= lr;
    // }
    // cout<<" smaller ";rep(i,1,n+1) cout<<s[i]<<" ";cout<<endl;
    // cout<<" larger ";rep(i,1,n+1) cout<<l[i]<<" ";cout<<endl;
    // bool out=false;
    // ll x=-1,y=-1,z=-1;
    // rep(i,0,n){
    //     if(s[arr[i]]>0 && l[arr[i]]>0) {
    //         out=true;
    //         y=i;
    //         rep(j,0,n){
    //             if(arr[j]<arr[i] && x==-1) x=j;
    //             if(arr[j]>arr[i] && z==-1) z=j;
    //         }
    //     }
    // }
    char dir='n';
    ll f=0,s=-1,t=-1;
    rep(i,1,n){
        if(dir=='n'){
            if(arr[i]>arr[f]){
                dir='i';
                s=i;
            }
            else if(arr[i]<arr[f]){
                dir='d';
                s=i;
            }
        }
        else{
            if(dir=='i'){
                if(arr[i]>arr[s]){
                    s=i;
                }
                else if(arr[i]<arr[s]){
                    t=i;
                    break;
                }
            }
            else if(dir=='d'){
                if(arr[i]>arr[s]){
                    t=i;
                    break;
                }
                else if(arr[i]<arr[s]){
                    s=i;
                }
            }
        }
    }
    if(s==-1 || t==-1) cout<<0<<endl;
    else{
        cout<<3<<endl<<f+1<<" "<<s+1<<" "<<t+1<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long long int lli;
typedef double db;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define sz(a) ll((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())             // for sets,maps etc O(log(n));
#define cpresent(c,x) (find(all(c),x) != (c).end())         // for vector and others O(n);
#define rep(i,a,b) for( int i = a; i < b; i++)
#define _USE_MATH_DEFINES
#define M 100000007

ll arr[100001];
ll s[1000010];
ll l[1000010];
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    rep(i,0,n){
        cin>>arr[i];
    }

    char dir='n';
    ll f=0,s=-1,t=-1;
    rep(i,1,n){
        if(dir=='n'){
            if(arr[i]>arr[f]){
                dir='i';
                s=i;
            }
            else if(arr[i]<arr[f]){
                dir='d';
                s=i;
            }
        }
        else{
            if(dir=='i'){
                if(arr[i]>arr[s]){
                    s=i;
                }
                else if(arr[i]<arr[s]){
                    t=i;
                    break;
                }
            }
            else if(dir=='d'){
                if(arr[i]>arr[s]){
                    t=i;
                    break;
                }
                else if(arr[i]<arr[s]){
                    s=i;
                }
            }
        }
    }
    if(s==-1 || t==-1) cout<<0<<endl;
    else{
        cout<<3<<endl<<f+1<<" "<<s+1<<" "<<t+1<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef long long int lli;
typedef double db;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define sz(a) ll((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())             // for sets,maps etc O(log(n));
#define cpresent(c,x) (find(all(c),x) != (c).end())         // for vector and others O(n);
#define rep(i,a,b) for( int i = a; i < b; i++)
#define _USE_MATH_DEFINES
#define M 100000007

ll arr[100001];
ll s[1000010];
ll l[1000010];
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    rep(i,0,n){
        cin>>arr[i];
    }

    char dir='n';
    ll f=0,s=-1,t=-1;
    rep(i,1,n){
        if(dir=='n'){
            if(arr[i]>arr[f]){
                dir='i';
                s=i;
            }
            else if(arr[i]<arr[f]){
                dir='d';
                s=i;
            }
        }
        else{
            if(dir=='i'){
                if(arr[i]>arr[s]){
                    s=i;
                }
                else if(arr[i]<arr[s]){
                    t=i;
                    // break;
                }
            }
            else if(dir=='d'){
                if(arr[i]>arr[s]){
                    t=i;
                    // break;
                }
                else if(arr[i]<arr[s]){
                    s=i;
                }
            }
        }
    }
    if(s==-1 || t==-1) cout<<0<<endl;
    else{
        cout<<3<<endl<<f+1<<" "<<s+1<<" "<<t+1<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
#define lli  long long int
#define ll long long
#define mod 1000000007
#define M 200005
#define pb push_back
#define FOR(a,b,c) for(int(a) = b;a<=c;a++)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define br cout<<'\n';
#define f(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define sz(a) a.size()
#define pii pair< int,int >
#define pll pair< ll,ll >
#define vii vector<pii>
#define vii vector<pii>
#define viii vector<tri>
#define pqueue priority_queue< int >
#define flush fflush(stdout)
#define in(a,n) lli a[n];for(lli i=0;i<n;i++)cin>>a[i];
#define printv(v) for(vector<lli> :: iterator itv=v.begin();itv!=v.end();itv++)cout<<*itv<<' ';br
#define prints(s) for(set<lli> :: iterator its=s.begin();its!=s.end();its++)cout<<*its<<' ';br
#define print2(a,b) cout<<a<<' '<<b;br
#define print3(a,b,c) cout<<a<<' '<<b<<' '<<c;br
#define print4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d;br
#define sum(a,n) lli sum=0;for(lli i=0;i<n;i++)sum+=a[i];
#define check cout<<"x"<<endl;
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);
#define upper(a) transform(a.begin(),a.end(),a.begin(),::toupper);

using namespace std;
//vector <lli> v;
//lli f[M];

lli modexp(lli a,lli n)
{
    lli r=1;
    while(n){
        if(n&1)
            r=(r*a)%mod;
        a=(a*a)%mod;
        n>>=1;
    }
    return r;
}

vector <pair < lli, lli> > remov;
lli dsu[2000];

lli root(lli p){
	if(dsu[p] < 0)
		return p;
	dsu[p] = root(dsu[p]);
	return dsu[p];
}

void dsu_merge(lli p, lli q){
	lli p1 = root(p);
	lli q1 = root(q);

	if(p1==q1){
		remov.pb(mp(p,q));
	}
	else
    {
		if(dsu[p1] > dsu[q1]){
			dsu[p1] = q1;
        }
        else if(dsu[p1] < dsu[q1]){
            dsu[q1] = p1;
        }
        else{
            dsu[q1] = p1;
            dsu[p1]--;
        }
	}
	return ;
}

void solve()
{

    lli n;
    cin>>n;
    in(a, n);
    vector < lli > v;
    lli arr[n];
    arr[0] = -1;
    f(i, 1, n)
    {
        if(a[i] > a[i - 1])
            arr[i] = 1;
        else
            arr[i] = 0;
    }
    v.pb(1);
    lli prev = -1;
    f(i, 1, n){
        if(arr[i] == 1){
            if(prev != 1)
                v.pb(i + 1), prev = arr[i];
            else
                v.pop_back(), v.pb(i + 1);
        }
        if(arr[i] == 0 && prev != 0){
            if(prev != 0)
                v.pb(i + 1), prev = arr[i];
            else
                v.pop_back(), v.pb(i + 1);
        }
        if(sz(v) == 3)
            break;
    }
    if(sz(v) >= 3)
    {
        cout<<3<<endl;
        rep(i, 3)
            cout<<v[i]<< ' ';
    }
    else
        cout<<0;
    return ;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    lli t;
//    cin>>t;
    t=1;
    while(t--)
    {
//        fill(dsu, dsu + 2000, -1);
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#define lli  long long int
#define ll long long
#define mod 1000000007
#define M 200005
#define pb push_back
#define FOR(a,b,c) for(int(a) = b;a<=c;a++)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define br cout<<'\n';
#define f(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define sz(a) a.size()
#define pii pair< int,int >
#define pll pair< ll,ll >
#define vii vector<pii>
#define vii vector<pii>
#define viii vector<tri>
#define pqueue priority_queue< int >
#define flush fflush(stdout)
#define in(a,n) lli a[n];for(lli i=0;i<n;i++)cin>>a[i];
#define printv(v) for(vector<lli> :: iterator itv=v.begin();itv!=v.end();itv++)cout<<*itv<<' ';br
#define prints(s) for(set<lli> :: iterator its=s.begin();its!=s.end();its++)cout<<*its<<' ';br
#define print2(a,b) cout<<a<<' '<<b;br
#define print3(a,b,c) cout<<a<<' '<<b<<' '<<c;br
#define print4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d;br
#define sum(a,n) lli sum=0;for(lli i=0;i<n;i++)sum+=a[i];
#define check cout<<"x"<<endl;
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);
#define upper(a) transform(a.begin(),a.end(),a.begin(),::toupper);

using namespace std;
//vector <lli> v;
//lli f[M];

lli modexp(lli a,lli n)
{
    lli r=1;
    while(n){
        if(n&1)
            r=(r*a)%mod;
        a=(a*a)%mod;
        n>>=1;
    }
    return r;
}

vector <pair < lli, lli> > remov;
lli dsu[2000];

lli root(lli p){
	if(dsu[p] < 0)
		return p;
	dsu[p] = root(dsu[p]);
	return dsu[p];
}

void dsu_merge(lli p, lli q){
	lli p1 = root(p);
	lli q1 = root(q);

	if(p1==q1){
		remov.pb(mp(p,q));
	}
	else
    {
		if(dsu[p1] > dsu[q1]){
			dsu[p1] = q1;
        }
        else if(dsu[p1] < dsu[q1]){
            dsu[q1] = p1;
        }
        else{
            dsu[q1] = p1;
            dsu[p1]--;
        }
	}
	return ;
}

void solve()
{

    lli n;
    cin>>n;
    in(a, n);
    lli ans = -1;
    for (int i=1;i < n - 1;i++)
    {
        if (a[i] > a[0] && a[i] > a[i + 1])
            ans = i + 1;
        if (a[i] < a[0] && a[i] < a[i + 1])
            ans = i + 1;
    }
    if(ans == -1)
        cout<<0;
    else
    {
        cout<<3<<endl;
        cout<<1<<' '<<ans<<' '<<ans + 1;
    }
    return ;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    lli t;
//    cin>>t;
    t=1;
    while(t--)
    {
//        fill(dsu, dsu + 2000, -1);
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
#define lli  long long int
#define ll long long
#define mod 1000000007
#define M 200005
#define pb push_back
#define FOR(a,b,c) for(int(a) = b;a<=c;a++)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define br cout<<'\n';
#define f(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define sz(a) a.size()
#define pii pair< int,int >
#define pll pair< ll,ll >
#define vii vector<pii>
#define vii vector<pii>
#define viii vector<tri>
#define pqueue priority_queue< int >
#define flush fflush(stdout)
#define in(a,n) lli a[n];for(lli i=0;i<n;i++)cin>>a[i];
#define printv(v) for(vector<lli> :: iterator itv=v.begin();itv!=v.end();itv++)cout<<*itv<<' ';br
#define prints(s) for(set<lli> :: iterator its=s.begin();its!=s.end();its++)cout<<*its<<' ';br
#define print2(a,b) cout<<a<<' '<<b;br
#define print3(a,b,c) cout<<a<<' '<<b<<' '<<c;br
#define print4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d;br
#define sum(a,n) lli sum=0;for(lli i=0;i<n;i++)sum+=a[i];
#define check cout<<"x"<<endl;
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);
#define upper(a) transform(a.begin(),a.end(),a.begin(),::toupper);

using namespace std;
//vector <lli> v;
//lli f[M];

lli modexp(lli a,lli n)
{
    lli r=1;
    while(n){
        if(n&1)
            r=(r*a)%mod;
        a=(a*a)%mod;
        n>>=1;
    }
    return r;
}

vector <pair < lli, lli> > remov;
lli dsu[2000];

lli root(lli p){
	if(dsu[p] < 0)
		return p;
	dsu[p] = root(dsu[p]);
	return dsu[p];
}

void dsu_merge(lli p, lli q){
	lli p1 = root(p);
	lli q1 = root(q);

	if(p1==q1){
		remov.pb(mp(p,q));
	}
	else
    {
		if(dsu[p1] > dsu[q1]){
			dsu[p1] = q1;
        }
        else if(dsu[p1] < dsu[q1]){
            dsu[q1] = p1;
        }
        else{
            dsu[q1] = p1;
            dsu[p1]--;
        }
	}
	return ;
}

void solve()
{

    lli n;
    cin>>n;
    in(a, n);
    vector < lli > v;
    lli arr[n];
    arr[0] = -1;
    f(i, 1, n)
    {
        if(a[i] > a[i - 1])
            arr[i] = 1;
        else
            arr[i] = 0;
    }
    v.pb(1);
    lli prev = -1;
    f(i, 1, n){
        if(arr[i] == 1 && prev != 1)
            v.pb(i + 1), prev = arr[i];
        if(arr[i] == 0 && prev != 0)
            v.pb(i + 1), prev = arr[i];
        if(sz(v) == 3)
            break;
    }
    if(sz(v) >= 3)
    {
        cout<<3<<endl;
        rep(i, 3)
            cout<<v[i]<< ' ';
    }
    else
        cout<<0;
    return ;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    lli t;
//    cin>>t;
    t=1;
    while(t--)
    {
//        fill(dsu, dsu + 2000, -1);
        solve();
    }
    return 0;
}