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.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.io.Writer;
import java.io.OutputStreamWriter;
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;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        CVasyaAndTheMushrooms solver = new CVasyaAndTheMushrooms();
        solver.solve(1, in, out);
        out.close();
    }

    static class CVasyaAndTheMushrooms {
        private long[][] arr;
        private long[][] dp;
        private long[][] K;
        private long[][] dpCache;
        private int n;

        private long solveDP(int i, int j) {
            if (j == n) return dpCache[i][j] = dp[i][j];
            if (dpCache[i][j] != -1) return dpCache[i][j];
            long k = K[i][j];
            if (i == 0)
                return dpCache[i][j] = Math.max(k * arr[0][j] + (k + 1) * arr[1][j] + solveDP(1, j + 1), dp[i][j]);
            else return dpCache[i][j] = Math.max(k * arr[1][j] + (k + 1) * arr[0][j] + solveDP(0, j + 1), dp[i][j]);
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            n = in.nextInt();
            arr = new long[2][n + 1];
            long[] preUp = new long[n + 1];
            long[] preDown = new long[n + 1];
            dp = new long[2][n + 1];
            for (int i = 1; i <= n; i++) {
                arr[0][i] = in.nextLong();
                preUp[i] = preUp[i - 1] + arr[0][i];
            }
            for (int i = 1; i <= n; i++) {
                arr[1][i] = in.nextLong();
                preDown[i] = preDown[i - 1] + arr[1][i];
            }
            dpCache = new long[2][n + 1];
            Arrays.fill(dpCache[0], -1);
            Arrays.fill(dpCache[1], -1);
            long lastUpK = (long) (Math.ceil((double) (n) / 2) - 1) * 4;
            long lastDownK = (long) ((n / 2) - 1) * 4 + 2;
            int lastUpKIndex = Util.isEven(n) ? n - 1 : n;
            int lastDownKIndex = Util.isEven(n) ? n : n - 1;
            K = new long[2][n + 1];
            int j = 1, start = 0;
            boolean down = true;
            while (j <= n) {
                if (down) {
                    K[0][j] = start++;
                    K[1][j] = start++;
                    down = false;
                } else {
                    K[1][j] = start++;
                    K[0][j] = start++;
                    down = true;
                }
                j++;
            }
            if (Util.isEven(n))
                dp[0][lastUpKIndex] = lastUpK * arr[0][lastUpKIndex] + (lastUpK + 1) * arr[0][lastUpKIndex + 1]
                        + (lastUpK + 2) * arr[1][lastUpKIndex + 1] + (lastUpK + 3) * arr[1][lastUpKIndex];
            else dp[0][lastUpKIndex] = lastUpK * arr[0][lastUpKIndex] + (lastUpK + 1) * arr[1][lastUpKIndex];

            for (j = lastUpKIndex - 2; j >= 1; j -= 2) {
                long k = K[0][j + 2], t = n - (j + 2) + 1;
                t <<= 1;
                dp[0][j] = dp[0][j + 2] - 2 * (preUp[n] - preUp[j + 1] + preDown[n] - preDown[j + 1]) + k * (arr[0][j] + arr[0][j + 1] + arr[1][j + 1] + arr[1][j])
                        - 4 * arr[0][j] - 3 * arr[0][j + 1] + (t - 2) * arr[1][j + 1] + (t - 1) * arr[1][j];

            }
            if (Util.isEven(n))
                dp[1][lastDownKIndex] = lastDownK * arr[1][lastDownKIndex] + (lastDownK + 1) * arr[0][lastDownKIndex];
            else
                dp[1][lastDownKIndex] = lastDownK * arr[1][lastDownKIndex] + (lastDownK + 1) * arr[1][lastDownKIndex + 1]
                        + (lastDownK + 2) * arr[0][lastDownKIndex + 1] + (lastDownK + 3) * arr[0][lastDownKIndex];

            for (j = lastDownKIndex - 2; j >= 1; j -= 2) {
                long k = K[1][j + 2], t = n - (j + 2) + 1;
                t <<= 1;
                dp[1][j] = dp[1][j + 2] - 2 * (preUp[n] - preUp[j + 1] + preDown[n] - preDown[j + 1]) + k * (arr[1][j] + arr[1][j + 1] + arr[0][j + 1] + arr[0][j])
                        - 4 * arr[1][j] - 3 * arr[1][j + 1] + (t - 2) * arr[0][j + 1] + (t - 1) * arr[0][j];

            }
            out.println(solveDP(0, 1));
            out.flush();
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public InputReader(FileInputStream file) {
            this.stream = file;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res = (res << 3) + (res << 1) + c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res = (res << 3) + (res << 1) + c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;
        private ArrayList<String> res = new ArrayList<>();
        private StringBuilder sb = new StringBuilder("");

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void println(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                sb.append(objects[i]);
            }
            res.add(sb.toString());
            sb = new StringBuilder("");
        }

        public void close() {
            writer.close();
        }

        public void flush() {
            for (String str : res) writer.printf("%s\n", str);
            res.clear();
            sb = new StringBuilder("");
        }

    }

    static class Util {
        public static boolean isEven(int num) {
            return ((num & 1) == 0);
        }

    }
}

