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();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = in.nextInt();
            int[] b = new int[n];
            for (int i = 0; i < n; i++) b[i] = in.nextInt();
            long[] col = new long[n + 10];
            for (int i = n - 1; i >= 0; i--) {
                col[i] = a[i] + b[i] + col[i + 1];
            }
            long[] cs = new long[n + 10];
            for (int i = n - 1; i >= 0; i--) {
                cs[i] = b[i] * (1 + 2 * (n - 1 - i)) + col[i + 1] + cs[i + 1];
            }
            long ret = 0;
            for (int i = 0; i < n; i += 2) {
                ret = Math.max(ret, cs[i]);
                int t = i * 2;
                ret = Math.max(ret, t * a[i] + (t + 1) * b[i] +
                        (i < n - 1 ? (t + 2) * b[i + 1] + (t + 3) * a[i + 1] : 0) +
                        (t + 4) * col[i + 2] + cs[i + 2]);
            }
            out.println(ret);
        }

    }

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

    }
}

