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.io.OutputStream;
import java.io.Writer;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author palayutm
 */
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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            long[] a = new long[2 * n + 1];
            for (int i = 1; i <= n; i++) {
                a[i] = in.nextLong();
            }
            for (int i = 1; i <= n; i++) {
                a[2 * n - i + 1] = in.nextLong();
            }
            long[] ps = new long[2 * n + 1];
            long[] p1 = new long[2 * n + 1];
            long[] p2 = new long[2 * n + 1];
            for (int i = 1; i <= 2 * n; i++) {
                ps[i] = ps[i - 1] + a[i];
                p1[i] = p1[i - 1] + a[i] * i;
                p2[i] = p2[i - 1] + a[i] * (2 * n - i + 1);
            }
            long ans = 0, now = 0;
            for (int i = 1; i <= n; i++) {
                int t = (i - 1) * 2;
                int r = 2 * n - i + 1, l = i;
                if (i % 2 > 0) {
                    long sum = now + p1[r] - p1[l - 1] + (i - 2) * (ps[r] - ps[l - 1]);
                    ans = Math.max(ans, sum);
                    now += t * a[l] + (t + 1) * a[r];
                } else {
                    long sum = now + p2[r] - p2[l - 1] + (i - 2) * (ps[r] - ps[l - 1]);
                    ans = Math.max(ans, sum);
                    now += t * a[r] + (t + 1) * a[l];
                }
            }
            out.println(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] inbuf = new byte[1024];
        private int lenbuf = 0;
        private int ptrbuf = 0;

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

        private int readByte() {
            if (lenbuf == -1) throw new UnknownError();
            if (ptrbuf >= lenbuf) {
                ptrbuf = 0;
                try {
                    lenbuf = stream.read(inbuf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (lenbuf <= 0) return -1;
            }
            return inbuf[ptrbuf++];
        }

        public int nextInt() {
            int num = 0, b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

        public long nextLong() {
            long num = 0;
            int b;
            boolean minus = false;
            while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
            if (b == '-') {
                minus = true;
                b = readByte();
            }

            while (true) {
                if (b >= '0' && b <= '9') {
                    num = num * 10 + (b - '0');
                } else {
                    return minus ? -num : num;
                }
                b = readByte();
            }
        }

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream out) {
            super(out);
        }

        public OutputWriter(Writer out) {
            super(out);
        }

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

    }
}

