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())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = [0] * (n + 1)
time = 0
for i in range(n):
    if i % 2 == 0:
        tmp = time * a[i] + (time + 1) * b[i]
    else:
        tmp = (time + 1) * a[i] + (time) * b[i]
    ans[i + 1] = tmp + ans[i]
    time += 2
    

ab = a + b[::-1]
ba = b + a[::-1]
ruisekiab = [0] * (len(ab) + 1)
ruisekiba = [0] * (len(ba) + 1)
ruisekiab2 = [0] * (len(ab) + 1)
ruisekiba2 = [0] * (len(ba) + 1)

for i in range(len(ab)):
    ruisekiab[i + 1] = ruisekiab[i] + ab[i]
    ruisekiba[i + 1] = ruisekiba[i] + ba[i]   
    ruisekiab2[i + 1] = ruisekiab2[i] + ab[i] * i
    ruisekiba2[i + 1] = ruisekiba2[i] + ba[i] * i

for i in range(n + 1):
    if i % 2 == 0:
        ans[i] += (ruisekiab[2 * n - i] - ruisekiab[i]) * i
        ans[i] += (ruisekiab2[2 * n - i] - ruisekiab2[i])
        #for j in range(i, 2 * n - i):
        #    ans[i] += ab[j] * j
    else:
        ans[i] += (ruisekiba[2 * n - i] - ruisekiba[i]) * i
        ans[i] += (ruisekiba2[2 * n - i] - ruisekiba2[i])
        #for j in range(i, 2 * n - i):
        #    ans[i] += ba[j] * j 

print(max(ans))
