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.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[][] a = new int[2][n];
        for (int i = 0; i < n; i++)
            a[0][i] = in.nextInt();
        for (int i = 0; i < n; i++)
            a[1][i] = in.nextInt();

        int m = 0;
        int q = 0;
        int s = 0;

        int[] z = new int[n / 2];
        int[] zs = new int[n / 2];
        for (int i = 0; i < n / 2; i++) {
            q += a[0][2 * i] * s;
            s++;
            q += a[1][2 * i] * s;
            s++;
            q += a[1][2 * i + 1] * s;
            s++;
            q += a[0][2 * i + 1] * s;
            s++;
            z[i] = q;
            zs[i] = s;
        }

        for (int k = 0; k <= n / 2; k++) {
            if (k == 0) {
                q = 0;
                s = 0;
            } else {
                q = z[k - 1];
                s = zs[k - 1];
            }
            for (int i = 2 * k; i < n; i++) {
                q += a[0][i] * s;
                s++;
            }
            for (int i = n - 1; i >= 2 * k; i--) {
                q += a[1][i] * s;
                s++;
            }
            if (q > m)
                m = q;
        }

        int c = a[0][0] * 0 + a[1][0] * 1;
        for (int i = 0; i < n - 1; i++) {
            a[0][i] = a[1][i + 1];
            a[1][i] = a[0][i + 1];
        }
        n -= 1;

        q = 0;
        s = 0;
        for (int i = 0; i < n / 2; i++) {
            q += a[0][2 * i] * s;
            s++;
            q += a[1][2 * i] * s;
            s++;
            q += a[1][2 * i + 1] * s;
            s++;
            q += a[0][2 * i + 1] * s;
            s++;
            z[i] = q;
            zs[i] = s;
        }

        for (int k = 0; k <= n / 2; k++) {
            if (k == 0) {
                q = 0;
                s = 0;
            } else {
                q = z[k - 1];
                s = zs[k - 1];
            }
            for (int i = 2 * k; i < n; i++) {
                q += a[0][i] * s;
                s++;
            }
            for (int i = n - 1; i >= 2 * k; i--) {
                q += a[1][i] * s;
                s++;
            }
            if (q > m)
                m = q;
        }

        System.out.println(m);
    }
}