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

public class Mushrooms{
    
    static int N, M, K;
    static String s;
    static StringTokenizer st;
    static int[] d;
    
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));        
        PrintWriter out = new PrintWriter(System.out);
        
        int N = Integer.parseInt(br.readLine());
        
        int[] a = new int[N];
        int[] b = new int[N];
        
        st = new StringTokenizer(br.readLine());
        StringTokenizer st2 = new StringTokenizer(br.readLine());
        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(st.nextToken());
            b[i] = Integer.parseInt(st2.nextToken());
        }
        
        int[] a2 = new int[N+1];
        int[] b2 = new int[N+1];
        
        for (int i = 1; i <= N; i++) {
            a2[i] = a2[i-1] + a[i-1];
            b2[i] = b2[i-1] + b[i-1];
        }
        
        
        
        long ans = 0;
        
        long cur = 0;
        long ind = 0;
        for (int i = 0; i < N; i++) {
            cur += ind * a[i];
            ind++;
        }
        

        for (int i = N-1; i >= 0; i--) {
            cur += ind * b[i];
            ind++;
        }
        ans = cur;
        
        //System.out.println(cur);
        long rem = 2*N;
        for (int i = 1; i < N; i += 2) {
            cur += 2 * (a2[N] - a2[i]);
            cur += 2 * (b2[N] - b2[i+1]);
            rem -= 2;
            cur -= rem * b[i-1];
            rem -= 2;
            cur -= rem * b[i];
            //System.out.println(cur);
            ans = Math.max(ans,cur);
        }
        
        cur = 0;
        ind = 1;
        for (int i = 0; i < N; i++) {
            cur += ind * b[i];
            ind++;
        }
        for (int i = N-1; i > 0; i--) {
            cur += ind * a[i];
            ind++;
        }
        
        //System.out.println(cur);
        ans = Math.max(ans,cur);
        rem = 2*(N-1);
        for (int i = 2; i < N; i+= 2) {
            cur += 2 * (a2[N] - a2[i+1]);
            cur += 2 * (b2[N] - b2[i]);
            rem -= 2;
            cur -= rem * a[i-1];
            rem -= 2;
            cur -= rem * a[i];
            //System.out.println(cur);
            ans = Math.max(ans,cur);
        }
        
        
        
        out.println(ans);
        
        out.close();
    }    
}
