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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CVasyaAndTheMushrooms solver = new CVasyaAndTheMushrooms();
        solver.solve(1, in, out);
        out.close();
    }

    static class CVasyaAndTheMushrooms {
        int n;
        long[][] arr;
        long[][] suffix;
        long[][] secondSuffix;
        long[][] thirdSuffix;

        public void readInput(Scanner sc) {
            n = sc.nextInt();
            arr = new long[2][n];
            for (int i = 0; i < 2; i++)
                for (int j = 0; j < n; j++)
                    arr[i][j] = sc.nextInt();
        }

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            int q = 1;
            while (q-- > 0) {
                readInput(sc);
                suffix = new long[2][n];
                for (int i = 0; i < 2; i++)
                    for (int j = n - 1; j >= 0; j--) {
                        suffix[i][j] = arr[i][j];
                        if (j != n - 1)
                            suffix[i][j] += suffix[i][j + 1];
                    }
                secondSuffix = new long[2][n];
                for (int i = 0; i < 2; i++)
                    for (int j = n - 1; j >= 0; j--) {
                        secondSuffix[i][j] += suffix[i][j];
                        if (j != n - 1)
                            secondSuffix[i][j] += secondSuffix[i][j + 1];
                    }
                thirdSuffix = new long[2][n];
                for (int i = 0; i < 2; i++)
                    for (int j = n - 1; j >= 0; j--) {
                        thirdSuffix[i][j] = 1l * (n - j) * arr[i][j];
                        if (j != n - 1)
                            thirdSuffix[i][j] += thirdSuffix[i][j + 1];
                    }
                long max = 0;
                long prev = 0;
                int col = -1;
                int row = 0;
                int prevRow = 0;
                for (long i = 0; i < 2 * n; i++) {
                    if (i % 2 == 0)
                        col++;
                    if (i % 4 == 0 || i % 4 == 3)
                        row = 0;
                    else
                        row = 1;
                    long sum = 0;
                    sum += 1l * i * arr[row][col];
                    if (col + 1 < n) {
                        sum += 1l * i * suffix[row][col + 1];
                        sum += secondSuffix[row][col + 1];
                    }
                    long nextTime = i + n - 1 - col;
                    if (col + 1 < n) {
                        sum += 1l * nextTime * suffix[row ^ 1][col + 1];
                        sum += thirdSuffix[row ^ 1][col + 1];
                    }
                    if (row == prevRow && prevRow != -1)
                        sum += 1l * arr[row ^ 1][col] * (2 * n - 1);
                    max = Math.max(max, sum + prev);
                    prev += 1l * arr[row][col] * i;
                    prevRow = row;
                }
                pw.println(Math.max(max, prev));
            }
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            try {
                while (st == null || !st.hasMoreTokens())
                    st = new StringTokenizer(br.readLine());
                return st.nextToken();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

