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
input = sys.stdin.readline

n = int(input())
v = [[],[]]
v[0] = list(map(int,input().split()))
v[1] = list(map(int,input().split()))
dp = [0 for _ in range(n)]
dp1 = dp[:]
sum = v[0][n-1] + v[1][n-1]
dp[n-1] = sum + v[0][n-1]
dp1[n-1] = sum + v[1][n-1]
for i in range(n-2,-1,-1) : 
  xx = v[1][i] + 2*(n-i)*v[0][i]+sum
  dp[i] = xx + dp[i+1]
  xx = v[0][i] + 2*(n-i)*v[1][i] + sum
  dp1[i] = xx + dp1[i+1] 
  sum += v[1][i] + v[0][i]
mxmsum = sum
mxm = 0; sum = 0; turn = 0; time = 0
for i in range(0,n-1):
  if turn == 0 :
    mxm = max(mxm, sum+time * mxmsum + dp1[i+1] + (2*(n-i) - 1) * v[1][i])
    sum += time*(v[0][i]) + (time + 1)*v[1][i]
  else :
    mxm = max(mxm, sum+time*mxmsum + dp[i+1]+(2*(n-i)-1)*v[0][i])
    sum += time*(v[1][i]) + (time+1)*v[0][i]
  time += 2
  turn ^= 1
  mxmsum -= v[1][i] + v[0][i]
if turn : sum += time * v[1][n-1] + (time + 1) * v[0][n-1]
else : sum += time * v[0][n-1] + (time+1) * v[1][n-1]
print(max(mxm,sum))
