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.*;
        import java.util.Arrays;
        import java.util.BitSet;
        import java.util.Scanner;

public class Main {
    static int N=1010;

    static long[] a=new long[300010];
    static long[] b=new long[300010];
    static long sum,valz,valf,ans,fst;
    static int n,m,k,q,tot,root;
    static StreamTokenizer in=new StreamTokenizer(new BufferedReader((new InputStreamReader(System.in))));
    static int nextInt() throws IOException{
        in.nextToken();
        return (int)in.nval;
    }
    static String next() throws IOException{
        in.nextToken();
        return in.sval;
    }
    static PrintWriter out =new PrintWriter(new OutputStreamWriter(System.out));


    public static void main(String args[])throws IOException{
        n=nextInt();
        for(int i=1;i<=n;i++){
            a[i]=nextInt();
        }
        for(int i=1;i<=n;i++){
            b[i]=nextInt();
        }
        for(int i=1;i<=n;i++){
            sum+=a[i];
            valz+=(i-1)*a[i];
            valf+=(i-1)*b[i];
        }
        for(int i=1;i<=n;i++){
            sum+=b[n-i+1];
            valz+=(n+i-1)*b[n-i+1];
            valf+=(n+i-1)*a[n-i+1];
        }
        for(int i=0;i<n;i++){
            if(i%2==0){
                ans=Math.max(ans,fst+valz);
                fst+=(2*i)*a[i+1]+(2*i+1)*b[i+1];
                sum-=a[i+1]+b[i+1];
                valz=valz-(2*i)*a[i+1]-(2*n-1)*b[i+1]+sum;
                valf=valf-(2*i)*b[i+1]-(2*n-1)*a[i+1]+sum;
            }
            else{
                ans=Math.max(ans,fst+valf);
                fst+=(2*i)*b[i+1]+(2*i+1)*a[i+1];
                sum-=a[i+1]+b[i+1];
                valz=valz-(2*i)*a[i+1]-(2*n-1)*b[i+1]+sum;
                valf=valf-(2*i)*b[i+1]-(2*n-1)*a[i+1]+sum;
            }
        }
        ans=Math.max(ans,fst);
        out.println(ans);
        out.flush();
    }
}