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

public class MainD {

    private FastScanner in;
    private PrintWriter out;

    public void solve() {
        int n = in.nextInt();
        long[] a = new long[n];
        long[] b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = in.nextInt();
        }

        long[] sa_right = new long[n];
        long[] sb_right = new long[n];
        sa_right[n - 1] = a[n - 1];
        sb_right[n - 1] = b[n - 1];
        for (int i = n - 2; i >= 0; i--) {
            sa_right[i] = sa_right[i + 1] + a[i];
            sb_right[i] = sb_right[i + 1] + b[i];
        }

        long[] pa_right = new long[n];
        long[] pb_right = new long[n];
        long[] pa_left = new long[n];
        long[] pb_left = new long[n];
        pa_right[n - 1] = a[n - 1];
        pa_left[n - 1] = a[n - 1];
        pb_right[n - 1] = b[n - 1];
        pb_left[n - 1] = b[n - 1];
        for (int i = n - 2; i >= 0; i--) {
            pa_right[i] = pa_right[i + 1] + sa_right[i];
            pb_right[i] = pb_right[i + 1] + sb_right[i];
            pa_left[i] = pa_left[i + 1] + a[i] * (n - i);
            pb_left[i] = pb_left[i + 1] + b[i] * (n - i);
        }

        long mx = 0;
        long cur = 0;

        for (int i = 0; i < n; i++) {
            long rest;
            if (i % 2 == 0) {
                rest = ((2 * i - 1) * sa_right[i] + pa_right[i] +
                        (n + i - 1) * sb_right[i] + pb_left[i]);
            } else {
                rest = ((2 * i - 1) * sb_right[i] + pb_right[i] +
                        (n + i - 1) * sa_right[i] + pa_left[i]);
            }

            mx = Math.max(mx, cur + rest);

            if (i % 2 == 0) {
                cur += a[i] * (2 * i) + b[i] * (2 * i + 1);
            } else {
                cur += b[i] * (2 * i) + a[i] * (2 * i + 1);
            }
        }

        out.println(mx);
    }

    public void run() {
        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    class FastScanner {

        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    public static void main(String[] arg) {
        new MainD().run();
    }
}