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.InputMismatchException;
import java.io.IOException;
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);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.ni();
            long[] a = new long[n];
            long[] b = new long[n];
            for (int i = 0; i < n; ++i) a[i] = in.ni();
            for (int i = 0; i < n; ++i) b[i] = in.ni();
            long[] pa = new long[n + 1];
            pa[n - 1] = a[n - 1];
            for (int i = n - 2; i > -1; --i) pa[i] = a[i] + pa[i + 1];
            long[] pb = new long[n + 1];
            pb[n - 1] = b[n - 1];
            for (int i = n - 2; i > -1; --i) pb[i] = b[i] + pb[i + 1];
            long[] down = new long[n];
            for (int i = n - 2; i > -1; --i) {
                down[i] = down[i + 1] + b[i + 1] + pb[i + 2] + pa[i + 2] + a[i + 1] * 2 * (n - i - 1);
            }
            long[] up = new long[n];
            for (int i = n - 2; i > -1; --i) {
                up[i] = up[i + 1] + a[i + 1] + pb[i + 2] + pa[i + 2] + b[i + 1] * 2 * (n - i - 1);
            }
            long curr = 0;
            long ans = Integer.MIN_VALUE;
            for (int i = 0; i < 2 * n; ++i) {
                int col = i / 2;
                int row = 1;
                if ((i - col) % 2 == 0) row = 0;
                if (row == 0) curr += i * (a[col]);
                else curr += i * (b[col]);
                long rem = 0;
                if (row == 0) rem = up[col] + i * (pb[col + 1] + pa[col + 1]);
                else rem = down[col] + i * (pb[col + 1] + pa[col + 1]);
                if (ans < rem + curr) ans = rem + curr;
            }
            long lul = up[0] + b[0] * (2 * n - 1);
            ans = Math.max(ans, lul);
            out.print(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

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

        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 ni() {
            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 *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

