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.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;

public class Main2 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in  = new Scanner(System.in);
		int n = in.nextInt();
		int[][] a = new int[n][2];
		for(int i=0;i<n;i++) {
			a[i][0] = in.nextInt();
		}
		for(int i=0;i<n;i++) {
			a[i][1] = in.nextInt();
		}
		long cost = forward(a,n);
		cost = Math.max(cost, down(a,n));
		cost = Math.max(cost, snake(a,n));
		System.out.println(cost);
	}

	private static long snake(int[][] a, int n) {
		// TODO Auto-generated method stub
		int j=0;
		long cost=0;
		boolean flag=true;
		for(int i=0;i<n;i++) {
			if(flag) {
				cost+=a[i][0]*j;
				j++;
				cost+=a[i][1]*j;
				j++;
				flag=!flag;
			}
			else {
				cost+=a[i][1]*j;
				j++;
				cost+=a[i][0]*j;
				j++;
				flag=!flag;
			}
		}
		return cost;
	}

	private static long down(int[][] a, int n) {
		// TODO Auto-generated method stub
		long cost = 0;
		for(int i=0;i<n;i++) {
			cost+=(i+1)*a[i][1];
		}
		int j = n+1;
		for(int i=n-1;i>0;i--) {
			cost+=(j)*a[i][0];
			j++;
		}
		return cost;
	}

	private static long forward(int[][] a, int n) {
		// TODO Auto-generated method stub
		long cost = 0;
		for(int i=0;i<n;i++) {
			cost+=i*a[i][0];
		}
		int j = n;
		for(int i=n-1;i>=0;i--) {
			cost+=(j)*a[i][1];
			j++;
		}
		return cost;
	}
}