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.text.*;

public class Main{
    long mod = (int)1e9+7, IINF = (long)1e17;
    final int MAX = (int)1e6+1, INF = (int)1e9, root = 3;
    DecimalFormat df = new DecimalFormat("0.00000000");
    double PI = 3.141592653589793238462643383279502884197169399375105820974944;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }

    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        for(int i = 1, T= (multipleTC)?ni():1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }

    void solve(int TC) throws Exception{
        int n = ni();
        long[] a = new long[n], b = new long[n];
        for(int i = 0; i< n; i++)a[i] = nl();
        for(int i = 0; i< n; i++)b[i] = nl();
        long cur =0;
        for(int i = 0; i< n; i++)cur+=a[i]*i;
        for(int i = 0; i< n; i++)cur+=b[i]*(2*n-i-1);
        long[] Asuf1 = new long[n], Asuf2 = new long[n];
        long[] Bsuf1 = new long[n], Bsuf2 = new long[n];
        for(int i = n-1; i>= 0; i--){
            Asuf1[i] = -2*(n-i-1)*a[i];
            Asuf2[i] = 2*(n-i)*a[i];
            Bsuf1[i] = -2*(n-i-1)*b[i];
            Bsuf2[i] = 2*(n-i)*b[i];
            if(i<n-1){
                Asuf1[i]+=Asuf1[i+1];Asuf2[i]+=Asuf2[i+1];
                Bsuf1[i]+=Bsuf1[i+1];Bsuf2[i]+=Bsuf2[i+1];
            }
        }
        long ans = cur;
        for(int i = 1; i< n; i++){
            if(i%2==0){
                cur+=Asuf1[i-1]+Bsuf2[i];
                ans = Math.max(ans, cur);
            }else{
                cur+=Asuf2[i]+Bsuf1[i-1];
                ans = Math.max(ans, cur);
            }
        }
        pn(ans);
    }

    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bitcount(long n){return (n==0)?0:(1+bitcount(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

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

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

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

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