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.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class EducationalRound48C {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		out=new PrintWriter(new BufferedOutputStream(System.out));
		FastReader s=new FastReader();
		int n=s.nextInt();
		int[][] glade=new int[2][n];
		for(int i=0;i<n;i++) {
			glade[0][i]=s.nextInt();
		}
		for(int i=0;i<n;i++) {
			glade[1][i]=s.nextInt();
		}
		
		long ans=0;
		//first
		long temp=0;
		for(int i=0;i<(n);i++)
		{
			temp+=glade[0][i]*i;
		}
		int start=n;
		for(int i=n-1;i>=0;i--) {
			temp+=glade[1][i]*start;
			start++;
		}
		ans=Long.max(ans,temp);
		//second
		temp=0;
		for(int i=1;i<=n;i++) {
			temp+=glade[1][i-1]*i;
		}
		start=n+1;
		for(int i=n-1;i>=1;i--) {
			temp+=glade[0][i]*start;
			start++;
		}
		ans=Long.max(temp,ans);
		
		//third
		temp=0;
		start=0;
		for(int i=0;i<n;i++) {
			if(i%2==0) {//down
				temp+=glade[0][i]*start;
				start++;
				temp+=glade[1][i]*start;
				start++;
			}
			else {
				temp+=glade[1][i]*start;
				start++;
				temp+=glade[0][i]*start;
				start++;
			}
		}
		ans=Long.max(ans,temp);
		out.println(ans);
		out.close();
	}
	
	
	public static PrintWriter out;
	
		public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}
