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.io.*;
import java.math.BigInteger;

public class Main
{
    static final long mod=1000000007;
    public static void main(String[] args) throws Exception
    {
    	FastReader in=new FastReader();
    	PrintWriter pw=new PrintWriter(System.out);
    	int n=in.nextInt();
    	long[][] arr=new long[2][n+1];
    	long[][] sum=new long[2][n+1];
    	long[][] fsum=new long[2][n+1];
    	long[][] rsum=new long[2][n+1];
    	for(int j=0;j<2;j++)
    		for(int i=0;i<n;i++)
    			arr[j][i]=in.nextInt();
    	for(int j=0;j<2;j++)
    	{
    		int k=n;
    		for(int i=n-1;i>=0;i--)
    		{
    			sum[j][i]=sum[j][i+1]+arr[j][i];
    			fsum[j][i]=fsum[j][i+1]+i*arr[j][i];
    			rsum[j][i]=rsum[j][i+1]+k*arr[j][i];
    			k++;
    		}
    	}
    	long ans=0,cur=0,t=0;
    	int j=0;
    	for(int i=0;i<n;i++)
    	{
    		long a=fsum[j][i]+(t-i)*sum[j][i]+rsum[1-j][i]+(t-i)*sum[1-j][i];
    		ans=Math.max(ans,a+cur);
    		cur+=t*arr[j][i];
    		j=1-j;
    		t++;
    		a=fsum[j][i]+(t-i)*sum[j][i]+rsum[1-j][i+1]+(t-i)*sum[1-j][i+1];
    		ans=Math.max(ans,a+cur);
    		cur+=t*arr[j][i];
    		t++;
    	}
    	pw.println(ans);
    	pw.flush();
    }
}

class FastReader
{
    BufferedReader br;
    StringTokenizer st;
 
    public FastReader()
    {
        br=new BufferedReader(new InputStreamReader(System.in));
    }
 
    public String next() throws IOException
    {
        if(st==null || !st.hasMoreElements())
        {
            st=new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
 
    public int nextInt() throws IOException
    {
        return Integer.parseInt(next());
    }
 
    public long nextLong() throws IOException
    {
        return Long.parseLong(next());
    }
}