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.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

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

    static class CVasyaAndTheMushrooms {
        public void solve(int testNumber, Scan in, PrintWriter out) {
            int n = in.scanInt();
            long a[][] = new long[n][2];
            long up[][] = new long[n][2];

            for (int i = 0; i < n; i++) a[i][0] = in.scanLong();

            for (int i = 0; i < n; i++) a[i][1] = in.scanLong();

            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    up[i][0] = (i >= 1 ? up[i - 1][0] : 0) + (a[i][0] * 2 * i);
                    up[i][1] = up[i][0] + (a[i][1] * (2 * i + 1));
                } else {
                    up[i][1] = (i >= 1 ? up[i - 1][1] : 0) + a[i][1] * (2 * i);
                    up[i][0] = up[i][1] + a[i][0] * (2 * i + 1);
                }
            }
            long pre[][] = new long[n][2];
            pre[n - 1][0] = a[n - 1][0];
            pre[n - 1][1] = a[n - 1][1];
            for (int i = n - 2; i >= 0; i--) {
                pre[i][0] += pre[i + 1][0];
                pre[i][1] += pre[i + 1][1];
            }
            long ans = Math.max(up[n - 1][0], up[n - 1][1]);
            long total = 0;
            for (int i = 0; i < n; i++) {
                total += i * a[i][0];
                total += (2 * n - 1 - i) * a[i][1];
            }
            ans = Math.max(total, ans);
            int t = 0;
            for (int i = 2; i < n; i += 2) {
                total += (2 * pre[i][0]);
                total += (2 * pre[i][1]);
                total -= a[i - 2][1] * (2 * n - 1);
                total -= a[i - 1][1] * (2 * n - 2);
                total -= a[i - 1][0] * (t + 1);
                total += (a[i - 2][1] * (t + 1));
                total += (a[i - 1][1] * (t + 2));
                total += (a[i - 1][0] * (t + 3));
                ans = Math.max(total, ans);
                t += 4;
            }
            long f = a[0][1];
            for (int i = 1; i < n; i++) {
                f += (2 * n - i) * a[i][0];
                f += (i + 1) * a[i][1];
            }
            ans = Math.max(f, ans);
            t = 2;
            for (int i = 3; i < n; i += 2) {
                f += (2 * pre[i][0]);
                total += (2 * pre[i][1]);
                f -= a[i - 2][0] * (2 * n - 1);
                f -= a[i - 1][0] * (2 * n - 2);
                f -= a[i - 1][1] * (t + 1);
                f += (a[i - 2][0] * (t + 1));
                f += (a[i - 1][0] * (t + 2));
                f += (a[i - 1][1] * (t + 3));
                ans = Math.max(f, ans);
                t += 4;
            }
            out.println(ans);

        }

    }

    static class Scan {
        private byte[] buf = new byte[4 * 1024];
        private int INDEX;
        private BufferedInputStream in;
        private int TOTAL;

        public Scan(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (INDEX >= TOTAL) {
                INDEX = 0;
                try {
                    TOTAL = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (TOTAL <= 0) return -1;
            }
            return buf[INDEX++];
        }

        public int scanInt() {
            int I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

        public long scanLong() {
            long I = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    I *= 10;
                    I += n - '0';
                    n = scan();
                }
            }
            return neg * I;
        }

    }
}

