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;
        long[] _upTail;
        long[] _downTail;
        long[] _calc;

        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 = 0;
            for (int i = 0; i < n; i++) {
                ans = Math.max(ans, calc(i) + tail(i));
            }
            out.println(ans);
        }

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

        long tail(int pos) {
            long res = 0;
            if (pos % 2 == 0) {
                res += upTail(pos);
            } else {
                res += downTail(pos);
            }
            return res;
        }

        long upTail(int pos) {
            if (_upTail == null) {
                _upTail = new long[n];
                long[] up = new long[n];
                long[] down = new long[n];
                long sum = a[n - 1];
                up[n - 1] = 2 * (n - 1) * (long) a[n - 1];
                for (int i = n - 2; i >= 0; i--) {
                    up[i] = up[i + 1] - sum + 2 * i * (long) a[i];
                    sum += a[i];
                }
                down[n - 1] = (2 * n - 1) * (long) b[n - 1];
                sum = b[n - 1];
                for (int i = n - 2; i >= 0; i--) {
                    down[i] = down[i + 1] - sum + (2 * n - 1) * (long) b[i];
                    sum += b[i];
                }
                for (int i = 0; i < n; i++) {
                    _upTail[i] = up[i] + down[i];
                }
            }
            return _upTail[pos];
        }

        long downTail(int pos) {
            if (_downTail == null) {
                _downTail = new long[n];
                long[] up = new long[n];
                long[] down = new long[n];
                long sum = b[n - 1];
                down[n - 1] = 2 * (n - 1) * (long) b[n - 1];
                for (int i = n - 2; i >= 0; i--) {
                    down[i] = down[i + 1] - sum + 2 * i * (long) b[i];
                    sum += b[i];
                }
                up[n - 1] = (2 * n - 1) * (long) a[n - 1];
                sum = a[n - 1];
                for (int i = n - 2; i >= 0; i--) {
                    up[i] = up[i + 1] - sum + (2 * n - 1) * (long) a[i];
                    sum += a[i];
                }
                for (int i = 0; i < n; i++) {
                    _downTail[i] = up[i] + down[i];
                }
            }
            return _downTail[pos];
        }

    }

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

    }
}

