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 sys
import math
input = sys.stdin.readline
from functools import cmp_to_key;

def pi():
    return(int(input()))
def pl():
    return(int(input(), 16))
def ti():
    return(list(map(int,input().split())))
def ts():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
mod = 998244353;
f = [];
def fact(n,m):
    global f;
    f = [1 for i in range(n+1)];
    f[0] = 1;
    for i in range(1,n+1):
        f[i] = (f[i-1]*i)%m;

def fast_mod_exp(a,b,m):
    res = 1;
    while b > 0:
        if b & 1:
            res = (res*a)%m;
        a = (a*a)%m;
        b = b >> 1;
    return res;

def inverseMod(n,m):
    return fast_mod_exp(n,m-2,m);

def ncr(n,r,m):
    if r == 0: return 1;
    return ((f[n]*inverseMod(f[n-r],m))%m*inverseMod(f[r],m))%m;

def main():
    C();

dp = [];
def D():
    [n,k] = ti();
    a = ti();
    a = sorted(a);
    cnt = [0 for i in range(n)];
    for i in range(n):
        c = 0;
        for j in range(i,n):
            if a[j]-a[i] <= 5: c+=1;
            else:break;
        cnt[i] = c;
     
    global dp;
    dp = [[0 for j in range(k+1)] for i in range(n+1)];
    ans = 0;
    for i in range(n):
        for j in range(k+1):
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if j+1 <= k:
                dp[i+cnt[i]][j+1] = max(dp[i+cnt[i]][j+1], dp[i][j]+cnt[i]);
    print(dp[n][k]);
        

def C():
    n = pi();
    a = ti();
    b = ti();
    sumA123,sumB123,sumA321,sumB321,spSum = [0 for i in range(n)],[0 for i in range(n)],[0 for i in range(n)],[0 for i in range(n)],[0 for i in range(n)];
    smA = [0 for i in range(n)];
    smB = [0 for i in range(n)];
    for i in range(n):
        if i == 0:
            sumA123[i] = 0;
            sumB123[i] = 0;
            continue;
        sumA123[i] = sumA123[i-1] + (i*a[i]);
        sumB123[i] = sumB123[i-1] + (i*b[i]);

    for i in range(n-1,-1,-1):
        if i == n-1:
            sumA321[i] = a[i];
            sumB321[i] = b[i];
            continue;
        sumA321[i] = sumA321[i+1]+((n-i)*a[i]);
        sumB321[i] = sumB321[i+1]+((n-i)*b[i]);

    for i in range(n):
        if i == 0:
            spSum[i] = b[i];
        else:
            if i % 2 == 0:
                spSum[i] = spSum[i-1] + 2*i*a[i] + (2*i+1)*b[i];
            else:
                spSum[i] = spSum[i-1] + (2*i+1)*a[i] + 2*i*b[i];

    for i in range(n):
        if i == 0:
            smA[i] = a[i];
            smB[i] = b[i];
            continue;
        smA[i] = smA[i-1]+a[i];
        smB[i] = smB[i-1]+b[i];

    mx = 0;
    for i in range(n):
        if i == 0:
            mx = sumA123[n-1] + sumB321[i] + (2*i+n-1-i)*smB[n-1];
            continue;
        if i % 2 == 0:
            mx = max(mx, sumA123[n-1]-sumA123[i-1]+(2*i-i)*(smA[n-1]-smA[i-1])+sumB321[i]+(2*i+n-1-i)*(smB[n-1]-smB[i-1])+spSum[i-1]);
        else:
            mx = max(mx, sumB123[n-1]-sumB123[i-1]+(2*i-i)*(smB[n-1]-smB[i-1])+sumA321[i]+(2*i+n-1-i)*(smA[n-1]-smA[i-1])+spSum[i-1]);

    print(mx);
            


main();