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()] for j in range(2)]

ans = 0

def end(x, y, t):
    i = 1
    t += 1
    s = 0
    while x+i < n:
        s += t * A[y][x+i]
        i += 1
        t += 1

    y = (y+1) % 2
    i -= 1

    while x+i >= x:
        s += t * A[y][x+i]
        i -= 1
        t += 1

    return s

def find(x, y, t):
    if x == n-1:
        return (t+1) * A[(y+1)%2][x]
    
    elif x >= n-2:
        dx = (t+1) * A[y][x+1] + (t+2) * A[(y+1)%2][x+1]    
    else:
        dx = (t+1) * A[y][x+1] + (t+2) * A[y][x+2]
    dy = (t+1) * A[(y+1)%2][x] + (t+2) * A[(y+1)%2][x+1]
    if dx < dy:
        return end(x, y, t)
    return dy + find(x+1, (y+1)%2, t+2)

print(find(0, 0, 0))