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

// package contest;

import java.io.*;
import java.util.*;

public class lockoutb {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);

        int n = Integer.parseInt(br.readLine());

        long[][] glade = new long[2][n];
        for (int i = 0; i < 2; i++) {
            StringTokenizer st = new StringTokenizer(br.readLine());
            for (int j = 0; j < n; j++) {
                glade[i][j] = Integer.parseInt(st.nextToken()); //what the fawk is a glade
            }
        }

        long[][] tour = new long[2][n];
        long[][] suf = new long[2][n+1];
        for(int i = 0; i<2; i++){
            for(int j = 0; j<n; j++){
                tour[i][j] = (j)*glade[i][j] + (2*n-1-j)*glade[(i+1)%2][j]; //this might be wrong
                if(j-1 >= 0) tour[i][j] += tour[i][j-1];
                suf[i][j] = suf[i][j+1] + glade[i][j];
            }
        }
        
        long ret = 0;
        long sum = 0;
        int idx = 0; int time = 0;
        for(int i = 0; i<n; i++){
            long cur = sum + tour[idx][n-1];
            if(i-1 >= 0) cur -= tour[idx][i-1];
            ret = Math.max(ret, cur);
            sum += time*glade[idx][i]; time++; idx ^= 1;
            sum += time*glade[idx][i]; time++;
        }
        ret = Math.max(ret, sum);
        pw.println(ret);
        pw.close();
        br.close();
    }
}
