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
 *
 * @author Pradyumn
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(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, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] a = in.nextLongArray(n);
            long[] b = in.nextLongArray(n);
            long ans1 = getDLU(a, b);
            long ans2 = getD(a, b);
            out.println(Math.max(ans1, ans2));
        }

        private long getDLU(long[] a, long[] b) {
            int n = a.length;
            int[] aa = new int[n];
            int[] bb = new int[n];
            int time = 0;
            long sumA = 0;
            long sumB = 0;
            long fSumA = 0;
            long fSumB = 0;
            for (int i = 0; i < n; ++i) {
                fSumA += a[i] * time;
                aa[i] = time++;
                sumA += a[i];
            }
            for (int i = n - 1; i >= 0; --i) {
                fSumB += b[i] * time;
                bb[i] = time++;
                sumB += b[i];
            }

            long ans = fSumA + fSumB;
            long fSum = 0;
            time = 0;
            SegmentTreeSum segmentTreeSumA = new SegmentTreeSum(aa);
            SegmentTreeSum segmentTreeSumB = new SegmentTreeSum(bb);
            for (int i = 0; i < n; ++i) {
                fSumA -= segmentTreeSumA.getRangeSum(i, i) * a[i];
                fSumB -= segmentTreeSumB.getRangeSum(i, i) * b[i];
                sumA -= a[i];
                sumB -= b[i];
                if (i % 2 == 1) {
                    segmentTreeSumA.updateRange(i, n - 1, 2);
                    segmentTreeSumB.updateRange(i, n - 1, 2);
                    fSumA += 2 * sumA;
                    fSumB += 2 * sumB;
                    fSum += time * b[i];
                    ++time;
                    fSum += time * a[i];
                    ++time;
                    ans = Math.max(ans, fSum + fSumA + fSumB);
                } else {
                    fSum += time * a[i];
                    ++time;
                    fSum += time * b[i];
                    ++time;
                }
            }
            return ans;
        }

        private long getD(long[] a, long[] b) {
            int n = a.length;
            int[] aa = new int[n];
            int[] bb = new int[n];
            int time = 2;
            long sumA = 0;
            long sumB = 0;
            long fSumA = 0;
            long fSumB = 0;
            for (int i = 1; i < n; ++i) {
                fSumB += b[i] * time;
                bb[i] = time++;
                sumB += b[i];
            }
            for (int i = n - 1; i >= 1; --i) {
                fSumA += a[i] * time;
                aa[i] = time++;
                sumA += a[i];
            }

            long ans = fSumA + fSumB + b[0];
            long fSum = 0;
            time = 0;
            SegmentTreeSum segmentTreeSumA = new SegmentTreeSum(aa);
            SegmentTreeSum segmentTreeSumB = new SegmentTreeSum(bb);
            for (int i = 1; i < n; ++i) {
                fSumA -= segmentTreeSumA.getRangeSum(i, i) * a[i];
                fSumB -= segmentTreeSumB.getRangeSum(i, i) * b[i];
                sumA -= a[i];
                sumB -= b[i];
                if (i % 2 == 0) {
                    segmentTreeSumA.updateRange(i, n - 1, 2);
                    segmentTreeSumB.updateRange(i, n - 1, 2);
                    fSumA += 2 * sumA;
                    fSumB += 2 * sumB;
                    fSum += time * b[i];
                    ++time;
                    fSum += time * a[i];
                    ++time;
                    ans = Math.max(ans, fSum + fSumA + fSumB);
                } else {
                    fSum += time * a[i];
                    ++time;
                    fSum += time * b[i];
                    ++time;
                }
            }
            return ans;
        }

    }

    static class SegmentTreeSum {
        int[] lazy;
        int[] seg;
        int[] a;
        int size;
        int N;

        public SegmentTreeSum(int[] a) {
            this.N = a.length;
            size = 4 * N;
            seg = new int[size];
            lazy = new int[size];
            this.a = a;
            build(0, N - 1, 0);
        }

        public SegmentTreeSum(int n) {
            this.N = n;
            size = 4 * n;
            seg = new int[size];
            lazy = new int[size];
            a = new int[n];
            build(0, N - 1, 0);
        }

        private void build(int s, int e, int c) {
            if (s == e) {
                seg[c] = a[s];
                return;
            }
            int m = (s + e) >>> 1;
            build(s, m, 2 * c + 1);
            build(m + 1, e, 2 * c + 2);
            seg[c] = seg[2 * c + 1] + seg[2 * c + 2];
        }

        public long getRangeSum(int l, int r) {
            return getRangeSum(0, N - 1, 0, l, r);
        }

        private long getRangeSum(int s, int e, int c, int l, int r) {
            if (s > e || l > r || l > e || r < s) return 0;
            if (lazy[c] != 0) {
                if (s != e) {
                    lazy[2 * c + 1] += lazy[c];
                    lazy[2 * c + 2] += lazy[c];
                }
                seg[c] += (e - s + 1) * lazy[c];
                lazy[c] = 0;
            }
            if (s == e) {
                return seg[c];
            }
            if (s >= l && e <= r) {
                return seg[c];
            }
            int m = (s + e) >>> 1;
            return getRangeSum(s, m, 2 * c + 1, l, r)
                    + getRangeSum(m + 1, e, 2 * c + 2, l, r);
        }

        public void updateRange(int l, int r, int value) {
            updateRange(0, N - 1, 0, l, r, value);
        }

        private void updateRange(int s, int e, int c, int l, int r, int value) {
            if (s > e || l > r || l > e || r < s) return;
            if (lazy[c] != 0) {
                if (s != e) {
                    lazy[2 * c + 1] += lazy[c];
                    lazy[2 * c + 2] += lazy[c];
                }
                seg[c] += (e - s + 1) * (1L) * lazy[c];
                lazy[c] = 0;
            }
            if (s >= l && e <= r) {
                lazy[c] += value;
                return;
            }
            if (s == e) {
                seg[c] += value;
                return;
            }
            int m = (s + e) >>> 1;
            updateRange(s, m, 2 * c + 1, l, r, value);
            updateRange(m + 1, e, 2 * c + 2, l, r, value);
            seg[c] = seg[2 * c + 1] + seg[2 * c + 2];
        }

    }

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

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

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

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

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

        public long[] nextLongArray(int n) {
            long[] array = new long[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLong();
            }
            return array;
        }

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

    }
}

