6
12 8 12 17 20 5
17 4 8 8 8 4
 6
4 1 12 9 3 11
12 20 19 12 19 11
 1
1
1
 2
1 2
1 1
 1
7
5
 6
16 20 18 7 14 2
17 12 4 10 7 4

705
 917
 1
 9
 5
 741

#include<bits/stdc++.h>
#define REP(i,j,k) for(int i=j;i<k;++i)
#define RREP(i,j,k) for(int i=(int)j-1;i>=k;--i)
#define int long long
#define pb emplace_back
#define P pair<int,int>
#define F first
#define S second
#define ALL(x) x.begin(),x.end()
#define sz(a) (int)(a).size()
#define MX 105
#define oo 1e18
#define L(i) (i*2+1)
#define R(i) (i*2+2)
#define mid (l+r>>1)
#define MIN(x,y) (x=min(x,(y)))
#define MAX(x,y) (x=max(x,(y)))
#define mo (int)(1e9+7)
#define IOS cin.tie(0) ,cout.tie(0), cout.sync_with_stdio(0)
using namespace std;
int n,a[2][MX],l[2][MX],r[2][MX],c[2][MX],ans,v=1,sum,cnt=1;
main(){
	IOS;
	cin>>n;
	REP(i,0,2) REP(j,0,n){
		cin>>a[i][j];
		c[i][j] += a[i][j]; c[i][j+1] += c[i][j];
		l[i][j] += j*a[i][j]; l[i][j+1] += l[i][j];
	}
	REP(i,0,2) RREP(j,n,0) r[i][j] = a[i][j]*(n-j-1)+r[i][j+1];
	MAX(ans,l[0][n]+n*c[1][n]+r[1][0]);
	MAX(ans,l[1][n]+c[1][n]+r[0][1]+(n+1)*(c[0][n]-c[0][0]));
	REP(i,1,n){
		sum += a[v][i-1]*cnt; cnt++;
		sum += a[v][i]*cnt; cnt++;
		MAX(ans,sum+(l[v^1][n]-l[v^1][i-1])+(cnt-i)*(c[v^1][n]-c[v^1][i-1])
				+(r[v][i+1])+(2*n-1-i)*(c[v][n]-c[v][i]));
		v^=1;
	}
	cout<<ans;
}


