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.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author prakharjain
 */
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 {
        long[] dnsim;
        long[] dncom;
        long[] upsim;
        long[] upcom;
        long[] a;
        long[] b;
        int n;
        long asum = 0;
        long bsum = 0;
        long up2sum = 0;
        long dn2sum = 0;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            n = in.nextInt();

            a = new long[n];
            b = new long[n];

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

            for (int i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            for (int i = 0; i < n; i++) {
                asum += a[i];
                bsum += b[i];
            }

            //up 2nd
//        long up2sum = 0;
//        for (int i = 0; i < n; i++) {
//            up2sum += i * a[i];
//        }
//
//        for (int i = n - 1; i > 0; i--) {
//            up2sum += (n - i + n - 1) * b[i];
//        }
//
//        //down 2nd
//        long dn2sum = 0;
//        for (int i = 0; i < n; i++) {
//            dn2sum += i * b[i];
//        }
//        for (int i = n - 1; i > 0; i--) {
//            dn2sum += (n - i + n - 1) * a[i];
//        }

            upsim = new long[n];
            upcom = new long[n];
            dnsim = new long[n];
            dncom = new long[n];


            calup();
            caldown();

            long ans = Math.max(up2sum + (2l * n - 1) * b[0], dn2sum + (2l * n - 1) * a[0]);

            int ci = -1;
            long csum = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    ci++;
                    csum += ci * a[i];
                    ci++;
                    long nsum = csum;
                    nsum += dncom[i] + (ci * dnsim[i]);
                    ans = Math.max(nsum, ans);
                    csum += ci * b[i];
                } else {
                    ci++;
                    csum += ci * b[i];
                    ci++;
                    long nsum = csum;
                    nsum += upcom[i] + (ci * upsim[i]);
                    ans = Math.max(nsum, ans);
                    csum += ci * a[i];
                }
            }

            ans = Math.max(ans, csum);

            out.print(ans);
        }

        void calup() {
            for (int i = 0; i < n; i++) {
                up2sum += i * a[i];
            }

            for (int i = n - 1; i > 0; i--) {
                up2sum += (n - i + n - 1) * b[i];
            }

            upsim[0] = asum + bsum - b[0];

            for (int i = 1; i < n; i++) {
                upsim[i] = upsim[i - 1] - a[i - 1] - b[i];
            }
            upcom[0] = up2sum;
            for (int i = 1; i < n; i++) {
                upcom[i] = upcom[i - 1] - upsim[i - 1];
                long rl = (2l * (n - i)) - 1;
                upcom[i] -= rl * b[i];
            }
        }

        void caldown() {
            for (int i = 0; i < n; i++) {
                dn2sum += i * b[i];
            }
            for (int i = n - 1; i > 0; i--) {
                dn2sum += (n - i + n - 1) * a[i];
            }

            dnsim[0] = asum + bsum - a[0];

            for (int i = 1; i < n; i++) {
                dnsim[i] = dnsim[i - 1] - b[i - 1] - a[i];
            }
            dncom[0] = dn2sum;
            for (int i = 1; i < n; i++) {
                dncom[i] = dncom[i - 1] - dnsim[i - 1];
                long rl = (2l * (n - i)) - 1;
                dncom[i] -= rl * a[i];
            }
        }

    }

    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 static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        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 nextInt() {
            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 interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

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

        public void print(long i) {
            writer.print(i);
        }

    }
}

