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())
mas = list(map(int, input().split()))
gas = list(map(int, input().split()))
#1
vsp = gas[::-1]
ras1 = [i * mas[i] for i in range(n)]
ras2 = [(i+n) * vsp[i] for i in range(n)]
otv1 = sum(ras1) + sum(ras2)
#2
vsp = mas[::-1]
q2 = 1 + n
ras1 = [(i + 1) * gas[i] for i in range(n)]
ras2 = [(q2 + i ) * vsp[i] for i in range(n)]
otv2 = sum(ras1) + sum(ras2[:-1])
#3
ras1 = [(i-1) * 4* mas[i] for i in range(0,n,2) if i != 0]
ras2 = [((i-1) * 4 - 1)* mas[i] for i in range(1,n,2) if i != 1]
ras3 = [((i-1) * 4 - 2)* gas[i] for i in range(1,n,2) if i != 1]
ras4 = [((i-1) * 4  + 1)* gas[i] for i in range(0,n,2) if i != 0]
otv3 = sum(ras1) + sum(ras2) + sum(ras3) + sum(ras4) + gas[0] + gas[1] * 2 + mas[1] * 3

print(max([otv1, otv2, otv3]))