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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;

public class Solution{
	
	
    public static void main(String[] args) {
     
    	FastScanner fs = new FastScanner();
    	PrintWriter out = new PrintWriter(System.out);
    		
    		
    	int tt = 1;
    	while(tt-->0) {
    			
    		
    		int n = fs.nextInt();
    		
    		int[][] a = new int[2][n];
    		
    		for(int i=0;i<2;i++) {
    			for(int j=0;j<n;j++) {
    				a[i][j] = fs.nextInt();
    			}
    		}
    		
    		
    		long[][] sum123 = new long[2][n+1];
    		long[][] sum321 = new long[2][n+1];
    		long[][] sum111 = new long[2][n+1];
    		
    		
    		for(int i=0;i<2;i++) {
    			for(int j=n-1;j>=0;j--) {
    				sum123[i][j] = sum123[i][j+1] + (long)(j)*a[i][j];
    				sum321[i][j] = sum321[i][j+1] + (long)(n-j-1)*a[i][j];
    				sum111[i][j] = sum111[i][j+1] + a[i][j];
    			}
    		}
    		
    		
    		long ans = 0;
    		long sum = 0;
    		
    		for(int i=0,j=0; j<n; j++,i ^= 1) {
    			long cur = sum;
    			cur += sum123[i][j] + (long)j*(sum111[i][j]);
    			cur += sum321[i^1][j] + (long)(j+n)*(sum111[i^1][j]);
    			ans = Math.max(ans, cur);
    			
    			sum += (long)(j+j)*a[i][j];
    			sum += (long)(j+j+1)*a[i^1][j];
    		}
    		

    		
    		out.println(ans);
    		
    	
    	}
    		
    	out.close();
    		
    }
    
    
    
    
  
    
    
    
    	
    static final Random random=new Random();
    	
    static void ruffleSort(long[] a) {
    	int n=a.length;//shuffle, then sort 
    	for (int i=0; i<n; i++) {
    		int oi=random.nextInt(n); long temp=a[oi];
    		a[oi]=a[i]; a[i]=temp;
    	}
    	Arrays.sort(a);
    }
    	
    	
    	
    static class FastScanner{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer("");
     
    	public String next(){
    		while(!st.hasMoreElements()){
    			try{
    				st = new StringTokenizer(br.readLine());
    			} catch(IOException e){
    				e.printStackTrace();
    			}
    		}
    		return st.nextToken();
    	}
    		
    	public String nextLine() throws IOException {
    		return br.readLine();
    	}
    		
    	public int nextInt(){
    		return Integer.parseInt(next());
    	}
     
    	public int[] readArray(int n){
    		int[] a = new int[n];
    		for(int i=0;i<n;i++)
    			a[i] = nextInt();
    		return a;
    	}
    		
    	public long nextLong() {
    		return Long.parseLong(next());
    	}
    		
    	public char nextChar() {
    		return next().toCharArray()[0];
    	}
    }
   	
}