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

n = int(input())
l = [[],[]]
for i in range(2) :
    l[i] = [int(i) for i in input().split(' ')]

pref = [[],[]]
for i in range(2) :
    pref[i].append(l[i][0])
    for j in range(1,n) :
        pref[i].append(pref[i][j-1] + l[i][j])

inc_pref = [[],[]]
tim_pref = [[],[]]
for i in range(2) :
    timer = 0
    tim_pref[i].append(0)
    inc_pref[i].append(timer*l[i][0])
    for j in range(1,n) :
        timer+=1
        inc_pref[i].append(inc_pref[i][j-1] + timer*l[i][j])
        tim_pref[i].append(timer)

inc_suff = [[],[]]
for i in range(2) :
    inc_suff[i] = [0 for _ in range(n)]
    timer = 0
    inc_suff[i][-1] = timer*l[i][-1]
    for j in range(n-2,-1,-1) :
        timer+=1
        inc_suff[i][j] = inc_suff[i][j+1] + timer*l[i][j]

i , j = 0 , 0
curr , ans = 0 , 0
timer = 0
while i < n :
    if j == 0:
        if i%2 == 0 :
            ans = max(ans , 
            curr + (timer - tim_pref[j][i])*(pref[j][-1] - (0 if i==0 else pref[j][i-1]))  + (inc_pref[j][-1] - (0 if i==0 else inc_pref[j][i-1]))
            + (n - i + timer)*(pref[j^1][-1] - (0 if i==0 else pref[j^1][i-1])) + inc_suff[j^1][i])
        else :
            ans = max(ans , 
            curr + (timer - tim_pref[j][i])*(pref[j][-1] - (0 if i==0 else pref[j][i-1]))  + (inc_pref[j][-1] - (0 if i==0 else inc_pref[j][i-1]))
            + (n - i + timer)*(pref[j^1][-1] - pref[j^1][i]) + (0 if i+1 == n else inc_suff[j^1][i+1]))
    else :
        if i%2 == 0 :
            ans = max(ans , 
            curr + (timer - tim_pref[j][i])*(pref[j][-1] - (0 if i==0 else pref[j][i-1]))  + (inc_pref[j][-1] - (0 if i==0 else inc_pref[j][i-1]))
            + (n - i + timer)*(pref[j^1][-1] - pref[j^1][i]) + (0 if i+1 == n else inc_suff[j^1][i+1]))
        else :
            ans = max(ans , 
            curr + (timer - tim_pref[j][i])*(pref[j][-1] - (0 if i==0 else pref[j][i-1]))  + (inc_pref[j][-1] - (0 if i==0 else inc_pref[j][i-1]))
            + (n - i + timer)*(pref[j^1][-1] - (0 if i==0 else pref[j^1][i-1])) + inc_suff[j^1][i])

    curr += timer*l[j][i]
    if (i%2 == 0 and j == 1) or (i%2 == 1 and j == 0) :
        i+=1
    else :
        j^=1
    timer+=1

print(ans)
