import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

void main() {
    auto N = readln.chomp.to!int;
    auto A = 2.iota.map!(_ => readln.split.map!(to!long).array).array;
    auto B = new long[][](2, N+1);

    foreach (i; 0..2)
        foreach (j; 0..N)
            B[i][j+1] = B[i][j] + A[i][j];

    long ans = 0;
    long tmp = 0;
    long a = 0;
    long b = 0;
    foreach (i; 0..N) a += i * A[0][i];
    foreach (i; 0..N) a += (N+N-i-1) * A[1][i];

    foreach (i; 1..N) b += (i + 1) * A[1][i];
    foreach (i; 1..N) b += (N+N-i) * A[0][i];

    foreach (i; 0..N) {
        long t = i*2;
        if (i % 2 == 0) {
            ans = max(ans, tmp + a);
            tmp += t * A[0][i];
            tmp += (t + 1) * A[1][i];
            if (i < N-2) {
                a -= t * A[0][i];
                a -= (t+1) * A[0][i+1];
                a += (B[0][N] - B[0][i+2]) * 2;
                a -= (2 * N - 1) * A[1][i];
                a -= (2 * N - 2) * A[1][i+1];
                a += (B[1][N] - B[1][i+2]) * 2;
            }
        } else {
            ans = max(ans, tmp + b);
            tmp += t * A[1][i];
            tmp += (t + 1) * A[0][i];
            if (i < N-2) {
                b -= t * A[1][i];
                b -= (t+1) * A[1][i+1];
                b += (B[1][N] - B[1][i+2]) * 2;
                b -= (2 * N - 1) * A[0][i];
                b -= (2 * N - 2) * A[0][i+1];
                b += (B[0][N] - B[0][i+2]) * 2;
            }
        }
        if (i == N-1) ans = max(ans, tmp);
    }

    ans.writeln;
}
