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.FileInputStream;
import java.io.FileNotFoundException;
import java.io.File;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Atharva Nagarkar
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        JoltyScanner in = new JoltyScanner(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, JoltyScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[][] grid = new int[2][n];
            for (int r = 0; r < 2; ++r) {
                for (int c = 0; c < n; ++c) {
                    grid[r][c] = in.nextInt();
                }
            }
            long best = 0;
            {
                long cur = 0;
                long t = 0;
                for (int c = 0; c < n; ++c, ++t) {
                    cur += t * grid[0][c];
                }
                for (int c = n - 1; c >= 0; --c, ++t) {
                    cur += t * grid[1][c];
                }
                best = Math.max(best, cur);
            }
            {
                long cur = 0;
                long t = 1;
                for (int c = 0; c < n; ++c, ++t) {
                    cur += t * grid[1][c];
                }
                for (int c = n - 1; c >= 1; --c, ++t) {
                    cur += t * grid[0][c];
                }
                best = Math.max(best, cur);
            }
            {
                long cur = 0;
                long t = 0;
                boolean down = true;
                int r = 0, c = 0;
                while (t < 2 * n) {
                    cur += t * grid[r][c];
                    if (down) {
                        r = (r + 1) % 2;
                    } else {
                        c++;
                    }
                    down = !down;
                    ++t;
                }
                best = Math.max(best, cur);
            }
            {
                BIT2D bitUp = new BIT2D(2, n);
                BIT2D bitDown = new BIT2D(2, n);
                BIT2D sum = new BIT2D(2, n);
                for (int r = 0; r < 2; ++r) {
                    for (int c = 0; c < n; ++c) {
                        sum.update(r + 1, c + 1, grid[r][c]);
                    }
                }
                long[][] timeUp = new long[2][n];
                long[][] timeDown = new long[2][n];
                { //go right, then down, then left
                    long t = 0;
                    for (int c = 0; c < n; ++c, ++t) {
                        bitUp.update(1, c + 1, t * grid[0][c]);
                        timeUp[0][c] = t;
                    }
                    for (int c = n - 1; c >= 0; --c, ++t) {
                        bitUp.update(2, c + 1, t * grid[1][c]);
                        timeUp[1][c] = t;
                    }
                }
                { //go down, then right, then up, then left
                    long t = 1;
                    for (int c = 0; c < n; ++c, ++t) {
                        bitDown.update(2, c + 1, t * grid[1][c]);
                        timeDown[1][c] = t;
                    }
                    for (int c = n - 1; c >= 1; --c, ++t) {
                        bitDown.update(1, c + 1, t * grid[0][c]);
                        timeDown[0][c] = t;
                    }
                }
//            System.out.println("time down: " + Arrays.deepToString(timeDown));
                long cur = 0;
                boolean down = true;
                long t = 0;
                int r = 0, c = 0;
                while (t < 2 * n) {
                    if (down) {
                        if (r == 0) {
                            long bb = cur + bitUp.query(r + 1, c + 1, 2, n) + (t - timeUp[r][c]) * sum.query(r + 1, c + 1, 2, n);
                            best = Math.max(best, bb);
                        } else {
                            long bb = cur + bitDown.query(r, c + 1, 2, n) + (t - timeDown[r][c]) * sum.query(r, c + 1, 2, n);
                            best = Math.max(best, bb);
                        }
                    }
                    cur += t * grid[r][c];
                    if (down) {
                        r = (r + 1) % 2;
                    } else {
                        c++;
                    }
                    ++t;
                    down = !down;
                }
            }
            out.println(best);
        }

    }

    static class JoltyScanner {
        public int BS = 1 << 16;
        public char NC = (char) 0;
        public byte[] buf = new byte[BS];
        public int bId = 0;
        public int size = 0;
        public char c = NC;
        public double num = 1;
        public BufferedInputStream in;

        public JoltyScanner(InputStream is) {
            in = new BufferedInputStream(is, BS);
        }

        public JoltyScanner(String s) throws FileNotFoundException {
            in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
        }

        public char nextChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            num = 1;
            boolean neg = false;
            if (c == NC) c = nextChar();
            for (; (c < '0' || c > '9'); c = nextChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = nextChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                num *= 10;
            }
            return neg ? -res : res;
        }

    }

    static class BIT2D {
        private long[][] tree;

        public BIT2D(int x, int y) {
            tree = new long[x + 1][y + 1];
        }

        public long query(int x, int y) {
            long val = 0;
            while (x > 0) {
                int y1 = y;
                while (y1 > 0) {
                    val += tree[x][y1];
                    y1 -= y1 & -y1;
                }
                x -= x & -x;
            }
            return val;
        }

        public long query(int start_x, int start_y, int end_x, int end_y) {
            return query(end_x, end_y) - query(start_x - 1, end_y) - query(end_x, start_y - 1) + query(start_x - 1, start_y - 1);
        }

        public void update(int x, int y, long val) {
            int y1;
            while (x < tree.length) {
                y1 = y;
                while (y1 < tree[x].length) {
                    tree[x][y1] += val;
                    y1 += (y1 & -y1);
                }
                x += (x & -x);
            }
        }

    }
}

