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.IOException;
import java.io.InputStreamReader;

public class C {

    private static int glade[][];
    private static int N;

    private static long maxMove() {
        return Math.max(firstWay(), Math.max(secondWay(), thirdWay()));
    }

    private static long firstWay() {
        long mush = 0;
        long mins = 0;
        for (int i = 0; i < N; i++, mins++) {
            mush += (mins * (long) glade[0][i]);
        }
        for (int i = N - 1; i >= 0; i--, mins++) {
            mush += (mins * (long) glade[1][i]);
        }
        return mush;
    }

    private static long secondWay() {
        long mush = 0;
        long mins = 1;
        for (int i = 0; i < N; i++, mins++) {
            mush += (mins * (long) glade[1][i]);
        }
        for (int i = N - 1; i >= 1; i--, mins++) {
            mush += (mins * (long) glade[0][i]);
        }
        return mush;
    }

    private static long thirdWay() {
        long mush = 0;
        long mins = 0;
        int i = 0, j = 0, k = 0;
        while (j < N) {
            mush += (mins * (long)glade[i][j]);
            switch (k) {
                case 0:
                    i++;
                    break;
                case 1:
                case 3:
                    j++;
                    break;
                case 2:
                    i--;
                    break;

            }
            mins++;
            k++;
            k %= 4;
        }
        return mush;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine().trim(), buffer[];
        N = Integer.parseInt(line);
        glade = new int[2][N];
        for (int i = 0; i < 2; i++) {
            line = br.readLine().trim();
            buffer = line.split("\\s+");
            for (int j = 0; j < N; j++) {
                glade[i][j] = Integer.parseInt(buffer[j]);
            }
        }
        System.out.println(maxMove());
    }

}
