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(raw_input())
a = [int(x) for x in raw_input().split()]
b = [int(x) for x in raw_input().split()]

L = [sum(a)+sum(b)]
for i in range(n-1):
    L.append(L[-1] - a[i] - b[i])
L.append(0)

ans = 0
current = 0
tail1 = sum([i * a[i] for i in range(n)]) + sum([(i+n) * b[n-1-i] for i in range(n)])
tail2 = sum([i * b[i] for i in range(n)]) + sum([(i+n) * a[n-1-i] for i in range(n)])
for i in range(n):
    if i % 2 == 0:
        ans = max(ans, current+tail1)
        current += b[i] + 2*L[i+1]
    else:
        ans = max(ans, current+tail2)
        current += a[i] + 2*L[i+1]
    tail1 += a[i] - 2 * (n-i-1) * b[i] - L[i]
    tail2 += b[i] - 2 * (n-i-1) * a[i] - L[i]
print max(ans,current)
