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.*;
import static java.lang.Math.*;
public class Main
{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        long a[][] = new long[2][n];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < n; j++) {
                a[i][j] = scan.nextInt();
            }
        }
        long l[][] = new long[2][n];
        long r[][] = new long[2][n];
        long suml[][] = new long[2][n];
        suml[0][n - 1] = a[0][n - 1];
        suml[1][n - 1] = a[1][n - 1];
        for (int i = n - 2; i >= 0; i--) {
            suml[0][i] += suml[0][i + 1] + a[0][i];
            suml[1][i] += suml[1][i + 1] + a[1][i];
        }
        for (int i = n - 2, t = 1; i >= 0; i--, t++) {
            l[0][i] = t * a[0][i] + l[0][i + 1];
            l[1][i] = t * a[1][i] + l[1][i + 1];
        }

        for (int i = 1; i < n; i++) {
            r[0][i] = i * a[0][i] + r[0][i - 1];
            r[1][i] = i * a[1][i] + r[1][i - 1];
        }
        long ans = 0, sum = 0;
        for (int i = 0, t = 0; i < n; i++, t++) {
            if (i % 2 == 0) {
                long rt = r[0][n - 1] - ((i-1>=0)?(r[0][i - 1]):0) + (t - i) * suml[0][i];
                long lt = l[1][i]+  (n - i + t) * suml[1][i]  ;
                ans = Math.max(sum + lt + rt, ans);
                sum += t * a[0][i] + (t + 1) * a[1][i];
                t++;
            } else {
                long rt = r[1][n - 1] -r[1][i - 1]  + (t - i) * suml[1][i];
                long lt = l[0][i]+ (n - i + t) * suml[0][i] ;
                ans = Math.max(sum + lt + rt, ans);
                sum += t * a[1][i] + (t + 1) * a[0][i];
                t++;
            }
        }
        System.out.println(ans);
    }
}