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];
            for (int i = 0; i < n; i++) {
                a[i][0] = in.scanLong();
            }
            for (int i = 0; i < n; i++) {
                a[i][1] = in.scanLong();
            }
            long up[] = new long[3];  /**0 small pos **1 big positin ** 3 value;*/
            long cir[] = new long[3];   /*0 samll pos ** 1 big position 3 value   */
            up[0] = -1;
            up[1] = -2;
            cir[0] = -1;
            cir[1] = 2 * n;
            for (int i = 0; i < n; i++) {
                long h = 0;
                long e = up[2];
                if (up[0] > up[1]) {
                    h = 2 * i * a[i][0] + (2 * n - 1) * a[i][1];
                    up[0]++;
                    up[1] = up[0] + 1;
                    up[2] += (up[0] * a[i][0]);
                    up[2] += (up[1] * a[i][1]);
                } else {
                    h = 2 * i * a[i][1] + (2 * n - 1) * a[i][0];
                    up[1]++;
                    up[0] = up[1] + 1;
                    up[2] += (up[0] * a[i][0]);
                    up[2] += (up[1] * a[i][1]);
                }
                long r = cir[0], t = cir[1];
                long g = 0;
                if (r > t) {
                    r--;
                    t++;
                    g = r * a[i][0] + t * a[i][1];
                    if (cir[2] + g > e + h) {
                        cir[0] = r;
                        cir[1] = t;
                        cir[2] += g;
                    } else {
                        if (i % 2 == 0) {
                            cir[0] = 2 * i;
                            cir[1] = 2 * n - 1;
                        } else {
                            cir[1] = 2 * i;
                            cir[0] = 2 * n - 1;
                        }
                        cir[2] = e + h;
                    }
                } else {
                    r++;
                    t--;
                    g = r * a[i][0] + t * a[i][1];
                    if (cir[2] + g > e + h) {
                        cir[0] = r;
                        cir[1] = t;
                        cir[2] += g;
                    } else {
                        if (i % 2 == 0) {
                            cir[0] = 2 * i;
                            cir[1] = 2 * n - 1;
                        } else {
                            cir[1] = 2 * i;
                            cir[0] = 2 * n - 1;
                        }
                        cir[2] = e + h;
                    }
                }
//            out.println("***"+i+"****");
//            out.println(up[0]+" "+up[1]+" "+up[2]);
//            out.println(cir[0]+" "+cir[1]+" "+cir[2]+" "+g+" "+h);
//            out.println();
            }
            out.println(Math.max(cir[2], up[2]));
        }

    }

    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;
        }

    }
}

