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

public class Solveaproblem {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(reader.readLine());
        long[] a = new long[n];
        StringTokenizer sToken = new StringTokenizer(reader.readLine());
        for (int i=0; i<n; i++) a[i] = Integer.parseInt(sToken.nextToken());
        long[] b = new long[n];
        sToken = new StringTokenizer(reader.readLine());
        for (int i=0; i<n; i++) b[i] = Integer.parseInt(sToken.nextToken());
        long x = 0, y = 0;
        long[] sum = new long[n];
        sum[n-1] = a[n-1] + b[n-1];
        int item = 3, m = 2 * n;
        x = a[n-1] * (m-1) + b[n-1] * (m-2);
        y = a[n-1] * (m-2) + b[n-1] * (m-1);
        for (int i=n-2; i>-1; i--) {
            sum[i] = sum[i + 1] + a[i] + b[i];
            x = x - sum[i+1] + (a[i] * (m-1) + b[i] * (m-item-1));
            y = y - sum[i+1] + (a[i] * (m-item-1) + b[i] * (m-1));
            item+=2;
        }
        long xy = 0, res = 0;
        int end = 1, ind = 0;
        item-=2;
        for (int i=0; i<n-1; i++) {
            if (end==0) res = Math.max(res, xy+x);
            else res = Math.max(res, xy+y);
            x = x + sum[i+1] - (a[i] * (m-1) + b[i] * (m-item-1));
            y = y + sum[i+1] - (a[i] * (m-item-1) + b[i] * (m-1));
            if (end==0) xy+=((ind+1) * a[i] + ind * b[i]);
            else xy+=(ind * a[i] + (ind+1) * b[i]);
            ind+=2;
            item-=2;
            end = 1-end;
        }
        if (end==0) res = Math.max(res, xy+x);
        else res = Math.max(res, xy+y);
        PrintWriter writer = new PrintWriter(System.out);
        writer.print(res);
        writer.close();
    }
}