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

import java.util.*;
import java.lang.*;
public class Solution {
	static Scanner in = new Scanner(System.in);
	
	public static void main(String []args){
		int n = in.nextInt();
 		long a[] = new long[n];
 		long b[] = new long[n];
 		for(int i = 0; i < n; i++)
 			a[i] = in.nextInt();
 		for(int i = 0; i < n; i++)
 			b[i] = in.nextInt();
 		long arraySum[] = new long[n];
 		for(int i = n-1; i >= 0; i--){
 			long x = a[i] + b[i];
 			if(i != n-1)
 				arraySum[i] = x + arraySum[i+1];
 			else
 				arraySum[i] = x;
 		}
 		long forwardSum[][] = new long[2][n];
 		long backwardSum[][] = new long[2][n];
 		int forIndex = 0;
 		forwardSum[0][0] = forIndex*a[0];
		backwardSum[1][0] = forIndex++*b[0];
 		for(int i = 1; i < n; i++){
 				forwardSum[0][i] = forIndex*a[i] + forwardSum[0][i-1];
 				backwardSum[1][i] = forIndex++*b[i] + backwardSum[1][i-1];
 		}
		forwardSum[1][n-1] = forIndex*b[n-1] + forwardSum[0][n-1];
		backwardSum[0][n-1] = forIndex++*a[n-1] + backwardSum[1][n-1];
 		for(int i = n-2; i >= 0; i--){
 			forwardSum[1][i] = forIndex*b[i] + forwardSum[1][i+1];
 			backwardSum[0][i] = forIndex++*a[i] + backwardSum[0][i+1];
 		}
 		long ans = 0, currentSum = 0;
 		for(int i = 0; i < n; i++){
 			int crossedCell = i*2;
 			long sum = 0;
 			if(i % 2 == 0){
 				if(i != 0)
 					sum = currentSum + forwardSum[1][i] - forwardSum[0][i-1] + i*(arraySum[i]);
 				else
 					sum = currentSum + forwardSum[1][i] - forwardSum[0][i] + i*(arraySum[i]);
 				ans = Math.max(sum,ans);
 				currentSum += crossedCell*a[i] + (crossedCell+1)*b[i];
 			}
 			else{
 				sum = currentSum + backwardSum[0][i] - backwardSum[1][i-1] + i*(arraySum[i]);
 				ans = Math.max(sum, ans);
 				currentSum += crossedCell*b[i] + (crossedCell+1)*a[i];
 			}
 		}
 		System.out.println(ans);
	}
}
