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

from heapq import heappush, heappop

n = input()
fr = map(int, raw_input().split(" "))
sr = map(int, raw_input().split(" "))

gr = [fr, sr]

s = set()
s.add((0, 0))
q = [] # collected, minute, x, y
heappush(q, [0, 0, 0, 0, s])

mox = None
while len(q) > 0:
    collected, minute, x, y, s = heappop(q)

    visited = False
    if x == 0:
        if (1, y) not in s:
            growth = (minute+1) * gr[1][y]
            heappush(q, [collected-growth, minute+1, 1, y, s | {(1, y)}])
            visited = True

    if y != 0:
        if (x, y-1) not in s:
            growth = (minute+1) * gr[x][y-1]
            heappush(q, [collected-growth, minute+1, x, y-1, s | {(x, y-1)}])
            visited = True

    if y != n-1:
        if (x, y+1) not in s:
            growth = (minute+1) * gr[x][y+1]
            heappush(q, [collected-growth, minute+1, x, y+1, s | {(x, y+1)}])
            visited = True


    if mox is None or mox < -1*collected:
        mox  = -1*collected

print mox


