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

//1016C
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n, step;
vector <int[2]> a(300007);
vector <long long[2]> s123(300007), s321(300007), s111(300007);
long long ans,lans,start;

int main()
{
	cin >> n;

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

	for (int p = 0;p < 2;++p)
		for (int i = n-1;i >= 0;--i)
		{
			s123[i][p] = s123[i + 1][p] + (i + 1) * 1LL * a[i][p];
			s321[i][p] = s321[i + 1][p] + (n - i) * 1LL * a[i][p];
			s111[i][p] = s111[i + 1][p] + a[i][p];
		}

	for (int i = 0, j = 0;i < n;++i, j ^= 1)
	{
		lans = start;
		lans += s123[i][j] + i * 1LL * s111[i][j];
		lans += s321[i][j ^ 1] + (i + n) * 1LL * s111[i][j ^ 1];
		
		ans = max(ans, lans);

		start += a[i][j] * 1LL * (2 * j + 1);
		start += a[i][j ^ 1] * 1LL * (2 * j + 2);
	}

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


	//for (int i = 0;i < n;++i)
	//{
	//	lans = 0;
	//	step = 0;
	//
	//	for (int j = 0;j < i;++j)
	//	{
	//		lans += a[j][(step + j) % 2] * step;
	//		++step;
	//		lans += a[j][(step + j) % 2] * step;
	//		++step;
	//	}
	//	
	//	int r = (step + i) % 2;
	//	for (int j = i;j < n;++j)
	//		lans += a[j][r] * step++;
	//
	//	r = (r + 1) % 2;
	//	for (int j = n-1;j >= i;--j)
	//		lans += a[j][r] * step++;
	//
	//	if (lans > ans)
	//		ans = lans;
	//}

	cout << ans;

	getchar();getchar();
	return 0;
}