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.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static long best;
    static int[] row1;
    static int[] row2;

    public static void main(String[] args) throws Exception {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());

        row1 = new int[n];
        row2 = new int[n];
        String[] te = in.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            row1[i] = Integer.parseInt(te[i]);
        }
        te = in.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            row2[i] = Integer.parseInt(te[i]);
        }

        best = 0;

        checkOne();
        checkTwo();

        System.out.println(best);
    }

    private static void checkTwo() {
        long cur = 0;
        int t = 0;
        for (int i = 0; i < row1.length; i++) {
            cur += (t * row1[i]);
            t++;
        }
        for (int i = row1.length - 1; i >= 0; i--) {
            cur += (t * row2[i]);
            t++;
        }
        best = Math.max(cur, best);
    }

    private static void checkOne() {
        long cur = 0;
        int t = 0;
        boolean goingUp = false;
        int curCol = 0;
        while (curCol != row1.length) {
            if (goingUp) {
                cur += t * row2[curCol];
                t++;
            } else {
                cur += t * row1[curCol];
                t++;
            }
            if (goingUp) {
                cur += t * row1[curCol];
                t++;
            } else {
                cur += t * row2[curCol];
                t++;
            }
            goingUp = !goingUp;
            curCol++;
        }
        best = Math.max(best, cur);
    }

}