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(i) for i in input().split()]
b = [int(i) for i in input().split()]
prefa = [int(0) for i in range(n)]
prefb = [int(0)for i in range(n)]
prefa1 = [int(0)for i in range(n)]
prefb1 = [int(0) for i in range(n)]
prefa2 = [int(0)for i in range(n)]
prefb2 = [int(0) for i in range(n)]
rs, bufsum, bufsum1  = 0, 0, 0
a[0] = 0
prefa[n-1] = (n-1)*a[n-1]
prefa1[n-1] = a[n-1]
prefb[n-1] = n*b[n-1]
prefb1[n-1] = b[n-1]
prefa2[n-1] = n*a[n-1]
prefb2[n-1] = (n-1)*b[n-1]
for i in range(n-2,-1,-1):
    prefa[i] = prefa[i+1]+a[i]*i
    prefa1[i] = prefa1[i+1]+a[i]
    prefb[i] = prefb[i+1]+b[i]*(n+n-i-1)
    prefb1[i] = prefb1[i+1]+b[i]
    prefa2[i] = prefa2[i+1]+a[i]*(n+n-i-1)
    prefb2[i] = prefb2[i+1]+b[i]*i
for i in range(n):
    if i % 2 == 0:
        bufsum1 = prefa[i] + prefb[i] + prefa1[i]*i + prefb1[i]*i
    else:
        bufsum1 = prefa2[i] + prefb2[i] + prefa1[i]*i + prefb1[i]*i
    rs = max(bufsum+bufsum1, rs)
    if i % 2 == 0:
        bufsum += 2*i*a[i] + (2*i+1)*b[i]
    else:
        bufsum += 2*i*b[i] + (2*i + 1)*a[i]
rs = max(rs, bufsum)
print(rs)
