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 {

    static int[][] a;
    static int[] zz;
    static int[] zs;
    static int m;

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

        m = 0;

        int s = 0;
        int q = 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++;
            zz[i + 1] = q;
            zs[i + 1] = s;
        }

        count(0, 0, n);

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

        count(2, c, n);

        System.out.println(m);
    }

    static void count(int ss, int c, int n) {
        for (int k = 0; k <= n / 2; k++) {
            int q = zz[k];
            int s = zs[k];


//            for (int i = 0; i < k; 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++;
//            }
            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;
        }
    }
}