#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define debug cout<<"ok"<<endl;
using namespace std;
int a[100000];
int s[100000];
int pmin[100000];
int main(){
int i,j,n,m,ans2=-1<<30,ans=-1<<30;
scanf("%d%d",&n,&m);
memset(s,0,sizeof(s));
memset(pmin,0,sizeof(pmin));
pmin[0]=0; s[0]=0;
for(int i=1;i<=n;i++)
{
cin>>a[i];
s[i]=s[i-1]+a[i];
pmin[i]=min(pmin[i-1],s[i]);
ans=max(ans,s[i]-pmin[i-1]);
// cout<<pmin[i]<<" "<<s[i]<<endl;
}
memset(s,0,sizeof(s));
memset(pmin,0,sizeof(pmin));
for(int i=1;i<=m;i++)
{
cin>>a[i];
s[i]=s[i-1]+a[i];
pmin[i]=min(pmin[i-1],s[i]);
ans2=max(ans2,s[i]-pmin[i-1]);
}
//out<<ans<<" "<<ans2<<" ";
cout<<ans*ans2;
return 0;
}
蟹蟹