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 functools
import sys

n = int(input())
first = list(map(int, input().split()))
sec = list(map(int, input().split()))

spiral = 0
i = 0
t = 0
while i < len(first):
    spiral += t * first[i]
    if i % 2 == 0:
        t += 3
    else:
        t += 1
    i += 1
i = 0
t = 1
while i < len(sec):
    spiral += t * sec[i]
    if i % 2 == 0:
        t += 1
    else:
        t += 3
    i += 1

clock = 0
t = 0
i = 0
while i < len(first):
    clock += t * first[i]
    t += 1
    i += 1
i = len(sec) - 1
while i >= 0:
    clock += t * sec[i]
    t += 1
    i -= 1

counter = 0
t = 1
i = 0
while i < len(sec):
    counter += t * sec[i]
    t += 1
    i += 1
i = len(first) - 1
while i > 0:
    counter += t * first[i]
    t += 1
    i -= 1

print(max(spiral, clock, counter))