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.*;
public class Main {

    public static void main(String args[]) throws Exception {
        Scanner in = new Scanner(System.in);

        int N = in.nextInt();
        long[][] input = new long[2][N];

        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < N; j++) {
                input[i][j] = in.nextLong();
            }
        }

        long MAX = 0;
        int index = 0;
        long lastcur = 0;
        long cur = 0;

        long sum1 = 0;
        long sum2 = 0;
        for (int i = 0; i < N; i++) {
            sum1 += input[0][i];
            sum2 += input[1][i];
        }

        while (index < N) {
            if (index == 0) {
                for (int i = 0; i < N; i++) {
                    lastcur += i * input[0][i];
                }
                for (int i = N - 1; i >= 0; i--) {
                    lastcur += (2*N-i-1) * input[1][i];
                }
                index++;
                MAX = Math.max(MAX, lastcur);
                sum1 -= input[0][0];
                sum2 -= input[1][0];
                continue;
            } else if (index == 1) {
                cur += input[1][0];
                for (int i = 1; i < N; i++) {
                    cur += (i+1) * input[1][i];
                }
                for (int i = N - 1; i >= 1; i--) {
                    cur += (2*N-i) * input[0][i];
                }
                index++;
                MAX = Math.max(MAX, cur);
                sum1 -= input[0][1];
                sum2 -= input[1][1];
                continue;
            }

            long tmp = lastcur;

            if (index % 2 == 0) {
                int corr = (index - 2) * 2;
                tmp -= corr * input[0][index - 2];
                tmp -= (corr + 1) * input[0][index - 1];
                tmp -= (2 * N - 1) * input[1][index - 2];
                tmp -= (2 * N - 2) * input[1][index - 1];
                tmp += corr * input[0][index - 2];
                tmp += (corr+1) * input[1][index - 2];
                tmp += (corr+2) * input[1][index - 1];
                tmp += (corr+3) * input[0][index - 1];
                tmp += 2 * sum1;
                tmp += 2 * sum2;
                sum1 -= input[0][index];
                sum2 -= input[1][index];
                MAX = Math.max(MAX, tmp);
                lastcur = cur;
                cur = tmp;
                index++;
            } else {
                int corr = (index - 2) * 2;
                tmp -= corr * input[1][index - 2];
                tmp -= (corr + 1) * input[1][index - 1];
                tmp -= (2 * N - 1) * input[0][index - 2];
                tmp -= (2 * N - 2) * input[0][index - 1];
                tmp += corr * input[1][index - 2];
                tmp += (corr+1) * input[0][index - 2];
                tmp += (corr+2) * input[0][index - 1];
                tmp += (corr+3) * input[1][index - 1];
                tmp += 2 * sum1;
                tmp += 2 * sum2;
                sum1 -= input[0][index];
                sum2 -= input[1][index];
                MAX = Math.max(MAX, tmp);
                lastcur = cur;
                cur = tmp;
                index++;
            }

//            int corr = index*2;
//            if (index % 2 == 0) {
//                for (int i = index; i < N; i++) {
//                    tmp += input[0][i]*(corr++);
//                }
//                for (int i = N - 1; i >= index; i--) {
//                    tmp += input[1][i]*(corr++);
//                }
//                MAX = Math.max(MAX, tmp);
//                corr = index*2;
//                cur += corr * input[0][index];
//                cur += (corr + 1) * input[1][index];
//            } else {
//                for (int i = index; i < N; i++) {
//                    tmp += input[1][i]*(corr++);
//                }
//                for (int i = N - 1; i >= index; i--) {
//                    tmp += input[0][i]*(corr++);
//                }
//                MAX = Math.max(MAX, tmp);
//                corr = index*2;
//                cur += corr * input[1][index];
//                cur += (corr + 1) * input[0][index];
//            }
//            index++;
        }
//        MAX = Math.max(MAX, cur);
        System.out.println(MAX);
    }
}