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 = input()
fst = [int(v) for v in raw_input().split()]
snd = [int(v) for v in raw_input().split()]
sfst = sum(fst)
ssnd = sum(snd)
slo = 0
shi = 0
for i in range(N):
    slo += i*fst[i] + (i+N)*snd[N-i-1]
    shi += i*snd[i] + (i + N)*fst[N-i-1]
MAX = slo
x,y = 0, 0
b = [fst, snd]
acc = 0
for i in range(N):
    acc += i*2*b[x][y]
    x = 0 if x else 1
    acc += (i*2 + 1)*b[x][y]
    sfst -= b[0][y]
    ssnd -= b[1][y]
    slo -= ssnd + sfst + (2*N - 2*i - 1)*b[1][y]
    shi -= ssnd + sfst + (2*N - 2*i - 1)*b[0][y]
    if x: 
        MAX = max(MAX, acc + shi + 2*(i+1)*(sfst + ssnd))
    else: 
        MAX = max(MAX, acc + slo + 2*(i + 1)*(sfst + ssnd))
    y += 1

print MAX
