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

import static java.lang.Long.max;

/**
 * Created by Minology on 07:42 SA
 */
public class C {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n;
        long ans = 0, cntdownup = -1, cntupdown = -1, downup = 0, updown = 0, s = 0, snake = 0;
        n = in.nextInt();
        int[] a = new int[n + 1];
        int[] b = new int[n + 1];
        for(int i = 1; i <= n; ++i) a[i] = in.nextInt();
        for(int i = 1; i <= n; ++i) b[i] = in.nextInt();
        for(int i = 1; i <= n; ++i){
            updown += a[i] * ++cntupdown;
            downup += b[i] * ++cntdownup;
            s += a[i] + b[i];
        }
        for(int i = n; i >= 1; --i){
            updown += b[i] * ++cntupdown;
            downup += a[i] * ++cntdownup;
        }
        ans = updown;
        for(int i = 1; i <= n; ++i){
            s -= a[i] + b[i];

            downup -= (long)a[i] * (2 * n - 1) + (long)b[i] * 2 * (i - 1) - s;
            if (i % 2 == 1){
                snake += (long)a[i] * (2 * i - 2) + (long)b[i] * (2 * i - 1);
                ans = max(ans, downup + snake);
            }

            updown -= (long)b[i] * (2 * n - 1) + (long)a[i] * 2 * (i - 1) - s;
            if (i % 2 == 0) {
                snake += (long)b[i] * (2 * i - 2) + (long)a[i] * (2 * i - 1);
                ans = max(ans, updown + snake);
            }
        }
        out.print(ans);
        in.close();
        out.close();
    }
}
