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())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

fr = [[0]*(n+1),[0]*(n+1)]
bk = [[0]*(n+1),[0]*(n+1)]
sm = [[0]*(n+1),[0]*(n+1)]

for i in range(n):
    j = n-1 - i
    fr[0][j] = a[j]
    fr[1][j] = b[j]

    bk[0][j] = a[j]
    bk[1][j] = b[j]
    
    fr[0][j] += fr[0][j+1] +  sm[0][j+1]
    fr[1][j] += fr[1][j+1] + sm[1][j+1]

    bk[0][j] += bk[0][j+1] + a[j]*i
    bk[1][j] += bk[1][j+1] + b[j]*i

    sm[0][j] = sm[0][j+1] + a[j]
    sm[1][j] = sm[1][j+1] + b[j]

best = 0
curr = 0
for i in range(n):
    curr += 2*i*a[i]
    val = curr + (2*i)*sm[0][i+1] + fr[0][i+1] + (n + i - 1)*sm[1][i] + bk[1][i]
    best = max(val,best)

    curr += (2*i + 1)*b[i]
    val = curr + (2*i + 1)*sm[1][i+1] + fr[1][i+1] + (n + i)*sm[0][i+1] + bk[1][i+1]
    best = max(val,best)

print(best)
