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.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author llamaoo7
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(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, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[][] g = new long[2][n + 10];
            long[] t = new long[n + 10];
            long[] ct = new long[n + 10];
            long[] cb = new long[n + 10];
            for (int i = 0; i < n; i++) g[0][i] = in.nextInt();
            for (int i = 0; i < n; i++) g[1][i] = in.nextInt();
            for (int i = n - 1; i >= 0; i--) t[i] = t[i + 1] + g[0][i] + g[1][i];
            for (int i = n - 1; i >= 0; i--) {
                ct[i] = ct[i + 1] + t[i + 1] + g[1][i] * ((n - i) * 2 - 1);
                cb[i] = cb[i + 1] + t[i + 1] + g[0][i] * ((n - i) * 2 - 1);
            }
            int curT = 0;
            long sum = 0;
            long ans = 0;
            for (int i = 0; i < n; i += 2) {
                ans = Math.max(ans, sum + ct[i] + t[i] * curT);
                sum += g[0][i] * curT + g[1][i] * (curT + 1);
                ans = Math.max(ans, sum + t[i + 1] * (curT + 2) + cb[i + 1]);
                sum += g[1][i + 1] * (curT + 2) + g[0][i + 1] * (curT + 3);
                ans = Math.max(ans, sum);
                curT += 4;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

