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
 */
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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int[] a;
        int[] b;
        int n;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            b = new int[n];
            for (int i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            long ans = calc(1);
            int p1 = 1;
            int p2 = 2 * n;
            while (p2 - p1 >= 3) {
                int m1 = p1 + (p2 - p1) / 3;
                int m2 = p2 - (p2 - p1) / 3;
                if (calc(m1) > calc(m2)) {
                    p2 = m2;
                } else {
                    p1 = m1;
                }
            }
            ans = Math.max(ans, calc(p2));
            ans = Math.max(ans, calc((p2 + p1) / 2));
            ans = Math.max(ans, calc(p1));
            out.println(ans);
        }

        long calc(int pos) {
            long res = 0;
            int cur = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    res += (2 * i) * (long) a[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumUp(cur, i + 1, i);
                    }
                    res += (2 * i + 1) * (long) b[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumDown(cur, i + 1, i + 1);
                    }
                } else {
                    res += (2 * i) * (long) b[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumDown(cur, i + 1, i);
                    }
                    res += (2 * i + 1) * (long) a[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumUp(cur, i + 1, i + 1);
                    }
                }
            }
            return res;
        }

        long sumUp(int ind, int from, int to) {
            long res = 0;
            for (int i = from; i < n; i++) {
                res += (long) a[i] * ind;
                ind++;
            }
            for (int i = n - 1; i >= to; i--) {
                res += (long) b[i] * ind;
                ind++;
            }
            return res;
        }

        long sumDown(int ind, int from, int to) {
            long res = 0;
            for (int i = from; i < n; i++) {
                res += (long) b[i] * ind;
                ind++;
            }
            for (int i = n - 1; i >= to; i--) {
                res += (long) a[i] * ind;
                ind++;
            }
            return res;
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

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

    }
}

