A little boy Laurenty has been playing his favourite game Nota for quite a while and is now very hungry. The boy wants to make sausage and cheese sandwiches, but first, he needs to buy a sausage and some cheese.

The town where Laurenty lives in is not large. The houses in it are located in two rows, n houses in each row. Laurenty lives in the very last house of the second row. The only shop in town is placed in the first house of the first row.

The first and second rows are separated with the main avenue of the city. The adjacent houses of one row are separated by streets.

Each crosswalk of a street or an avenue has some traffic lights. In order to cross the street, you need to press a button on the traffic light, wait for a while for the green light and cross the street. Different traffic lights can have different waiting time.

The traffic light on the crosswalk from the j-th house of the i-th row to the (j + 1)-th house of the same row has waiting time equal to a_{ij} (1 ≤ i ≤ 2, 1 ≤ j ≤ n - 1). For the traffic light on the crossing from the j-th house of one row to the j-th house of another row the waiting time equals b_{j} (1 ≤ j ≤ n). The city doesn't have any other crossings.

The boy wants to get to the store, buy the products and go back. The main avenue of the city is wide enough, so the boy wants to cross it exactly once on the way to the store and exactly once on the way back home. The boy would get bored if he had to walk the same way again, so he wants the way home to be different from the way to the store in at least one crossing. [Image] Figure to the first sample. 

Help Laurenty determine the minimum total time he needs to wait at the crossroads.


-----Input-----

The first line of the input contains integer n (2 ≤ n ≤ 50) — the number of houses in each row. 

Each of the next two lines contains n - 1 space-separated integer — values a_{ij} (1 ≤ a_{ij} ≤ 100). 

The last line contains n space-separated integers b_{j} (1 ≤ b_{j} ≤ 100).


-----Output-----

Print a single integer — the least total time Laurenty needs to wait at the crossroads, given that he crosses the avenue only once both on his way to the store and on his way back home.


-----Examples-----
Input
4
1 2 3
3 2 1
3 2 2 3

Output
12

Input
3
1 2
3 3
2 1 3

Output
11

Input
2
1
1
1 1

Output
4



-----Note-----

The first sample is shown on the figure above. 

In the second sample, Laurenty's path can look as follows:   Laurenty crosses the avenue, the waiting time is 3;  Laurenty uses the second crossing in the first row, the waiting time is 2;  Laurenty uses the first crossing in the first row, the waiting time is 1;  Laurenty uses the first crossing in the first row, the waiting time is 1;  Laurenty crosses the avenue, the waiting time is 1;  Laurenty uses the second crossing in the second row, the waiting time is 3.  In total we get that the answer equals 11.

In the last sample Laurenty visits all the crossings, so the answer is 4.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
N = int(input())
x = [[0] * N, [0] * N]
a = list(map(int, input().split()))
adash = [0]
for i in range(N - 1):
	adash.append(adash[-1] + a[i])
b = list(map(int, input().split()))
bdash = [0]
for i in range(N - 1):
	bdash.append(bdash[-1] + b[i])
c = list(map(int, input().split()))
kachra = []
for i in range(N):
	kachra.append(adash[i] + c[i] + bdash[-1] - bdash[i])
kachra.sort()
print(kachra[0] + kachra[1])


n = int(input())
row1 = [0] + [int(x) for x in input().split()]
row2 = [0] + [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
for i in range(1, n):
	row1[i] += row1[i - 1]
	row2[i] += row2[i - 1]
mini = 1000000000
for i in range(n):
	if row1[i] + b[i] + row2[n - 1] - row2[i] < mini:
		mini = row1[i] + b[i] + row2[n - 1] - row2[i]
		index = i
mini2 = 100000000
for i in range(n):
	if i != index and row1[i] + b[i] + row2[n - 1] - row2[i] < mini2:
		mini2 = row1[i] + b[i] + row2[n - 1] - row2[i]
print(mini + mini2)


n = int(input())
a = [0] + list(map(int, input().split()))
b = list(map(int, input().split())) + [0]
arr = list(map(int, input().split()))
for i in range(1, n):
	a[i] += a[i - 1]
	b[-i - 1] += b[-i]
m = 10 ** 12
for i in range(n):
	for j in range(i + 1, n):
		m = min(a[i] + b[i] + arr[i] + a[j] + b[j] + arr[j], m)
print(m)


n = int(input())
a = [int(i) for i in input().split(' ')]
c = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]
d = []
s1 = 0
s2 = sum(c)
z = b[0] + s2
d.append(z)
for i in range(1, n):
	z = b[i]
	s1 += a[i - 1]
	s2 -= c[i - 1]
	z += s1 + s2
	d.append(z)
d.sort()
print(d[0] + d[1])


import sys
read = lambda : list(map(int, sys.stdin.readline().split()))
(n,) = read()
a0s = read()
a1s = read()
bs = read()
best = 10 ** 8
for i in range(n):
	for j in range(i + 1, n):
		res = sum(a0s[:i]) + sum(a0s[:j]) + bs[i] + bs[j] + sum(a1s[i:]) + sum(a1s[j:])
		if res < best:
			best = res
print(best)


n = int(input())
mas1 = list(map(int, input().split(' ')))
mas2 = list(map(int, input().split(' ')))
mas3 = list(map(int, input().split(' ')))
sum1 = 0
sum2 = sum(mas2)
res = list()
for i in range(n):
	res.append(sum1 + sum2 + mas3[i])
	if i < n - 1:
		sum2 -= mas2[i]
		sum1 += mas1[i]
res.sort()
print(res[0] + res[1])


__author__ = 'Om Kumar Sahoo'
n = int(input())
first = [0] + [int(x) for x in input().split()]
second = [int(x) for x in input().split()] + [0]
st = [int(x) for x in input().split()]
firsts = [0] * n
seconds = [0] * n
for i in range(1, n):
	firsts[i] = firsts[i - 1] + first[i]
for i in range(n - 2, -1, -1):
	seconds[i] = seconds[i + 1] + second[i]
time = [0] * n
for i in range(n):
	time[i] = firsts[i] + seconds[i] + st[i]
m1 = min(time)
time.remove(m1)
m2 = min(time)
print(m1 + m2)


n = int(input())
across = [list(map(int, input().split())) for i in range(2)]
down = list(map(int, input().split()))
path = down[0] + sum(across[1])
costs = [path]
for (i, top) in enumerate(across[0]):
	bottom = across[1][i]
	path = path - down[i] - bottom + down[i + 1] + top
	costs.append(path)
costs.sort()
print(costs[0] + costs[1])


import functools
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
bb = [0] * N
for i in range(N - 1, 0, -1):
	bb[i - 1] = b[i - 1] + bb[i]
aa = [0] * N
for i in range(1, N):
	aa[i] = aa[i - 1] + a[i - 1]
res = []
for i in range(N):
	res.append(aa[i] + bb[i] + c[i])
res.sort()
print(res[0] + res[1])


n = int(input())
a1 = list(map(int, input().split(' ')[:n - 1]))
a2 = list(map(int, input().split(' ')[:n - 1]))
b = list(map(int, input().split(' ')[:n]))
x1 = 0
x2 = b[0]
cross = 0
for i in range(1, n):
	x1 = x1 + a1[i - 1]
	cross_way = x1 + b[i]
	pass_way = x2 + a2[i - 1]
	if cross_way < pass_way:
		cross = i
		x2 = cross_way
	else:
		x2 = pass_way
b[cross] = float('inf')
w1 = x2
x1 = 0
x2 = b[0]
for i in range(1, n):
	x1 = x1 + a1[i - 1]
	cross_way = x1 + b[i]
	pass_way = x2 + a2[i - 1]
	x2 = min(cross_way, pass_way)
print(w1 + x2)


def read_numbers():
	return list(map(int, input().split()))

def f(n, a1, a2, b):
	ways = [sum(a1[:h]) + b[h] + sum(a2[h:]) for h in range(n)]
	ways.sort()
	return sum(ways[:2])

def __starting_point():
	n = int(input())
	a1 = read_numbers()
	a2 = read_numbers()
	b = read_numbers()
	print(f(n, a1, a2, b))
__starting_point()


n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
b = list(map(int, input().split()))
a = list()
for i in range(n):
	a.append(sum(a1[:i]) + sum(a2[i:]) + b[i])
a.sort()
print(a[0] + a[1])


class CodeforcesTask586BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.upper = []
		self.lower = []
		self.crossing = []

	def read_input(self):
		self.n = int(input())
		self.upper = [int(x) for x in input().split(' ')]
		self.lower = [int(x) for x in input().split(' ')]
		self.crossing = [int(x) for x in input().split(' ')]

	def process_task(self):
		preu = [0] * (self.n - 1)
		prel = [0] * (self.n - 1)
		preu[0] = self.upper[0]
		prel[0] = self.lower[-1]
		for x in range(1, self.n - 1):
			preu[x] = preu[x - 1] + self.upper[x]
			prel[x] = prel[x - 1] + self.lower[-x - 1]
		prel = prel[::-1]
		ways = []
		for x in range(self.n - 2):
			ways.append(self.crossing[x + 1] + prel[x + 1] + preu[x])
		ways.append(self.crossing[0] + prel[0])
		ways.append(self.crossing[-1] + preu[-1])
		ways.sort()
		shortest = ways[0] + ways[1]
		self.result = str(shortest)

	def get_result(self):
		return self.result
Solution = CodeforcesTask586BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
l = []
for i in range(2):
	l.append([int(j) for j in input().split()])
l1 = [int(i) for i in input().split()]
l2 = []
for i in range(n):
	s = 0
	for j in range(i):
		s += l[0][j]
	s += l1[i]
	for j in range(i, n - 1):
		s += l[1][j]
	l2.append(s)
l2.sort()
print(l2[0] + l2[1])


n = int(input())
hor1 = [int(read) for read in input().split()]
hor2 = [int(read) for read in input().split()]
vert = [int(read) for read in input().split()]
pref1 = [0] * n
pref2 = [0] * n
for i in range(1, n):
	pref1[i] = pref1[i - 1] + hor1[i - 1]
	pref2[i] = pref2[i - 1] + hor2[i - 1]
mini = 10 ** 9
prev = 10 ** 9
ans = set()
for i in range(n):
	x = pref1[i] + (pref2[n - 1] - pref2[i]) + vert[i]
	if x <= mini:
		prev = mini
		mini = x
	elif x < prev:
		prev = x
print(mini + prev)


N = int(input())
A1s = list(map(int, input().split()))
A2s = list(map(int, input().split()))
Bs = list(map(int, input().split()))
scores = []
score = 0
for n in range(N):
	if n == 0:
		score = Bs[0] + sum(A2s)
	else:
		score -= Bs[n - 1]
		score += Bs[n]
		score -= A2s[n - 1]
		score += A1s[n - 1]
	scores.append(score)
scores.sort()
print(sum(scores[:2]))


n = int(input())
a1 = [int(x) for x in input().split()]
a2 = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
(best, best_cross) = (float('inf'), -1)
for i in range(n):
	tmp = sum(a1[:i]) + sum(a2[i:]) + b[i]
	if tmp < best:
		best = tmp
		best_cross = i
best2 = float('inf')
for i in range(n):
	if i == best_cross:
		continue
	tmp = sum(a1[:i]) + sum(a2[i:]) + b[i]
	if tmp < best2:
		best2 = tmp
print(best + best2)


a = int(input())
z = [[0] + list(map(int, input().split())), [0] + list(map(int, input().split()))]
r = [0] + list(map(int, input().split()))
k = []
for i in range(a, 0, -1):
	k.insert(0, sum(z[0][:i]) + r[i] + sum(z[1][i:]))
k1 = []
for i in range(1, a + 1):
	k1.insert(0, r[i] + sum(z[0][:i]) + sum(z[1][i:]))
s = float('inf')
k1 = k1[::-1]
for i in range(a):
	for j in range(a):
		if i != j:
			s = min(s, k[i] + k1[j])
print(s)


n = int(input())
a0s = list(map(int, input().split()))
a1s = list(map(int, input().split()))
bs = list(map(int, input().split()))

def solve(n, a0s, a1s, bs):
	cum = 0
	cum0s = [0]
	for a in a0s:
		cum += a
		cum0s.append(cum)
	cum = sum(a1s)
	cum1s = [cum]
	for a in a1s:
		cum -= a
		cum1s.append(cum)
	m = a0s[0]
	min0s = [m]
	for a in a0s[1:]:
		m = min(m, a)
		min0s.append(m)
	min0s.append(m)
	m = a1s[-1]
	min1s = [0] * n
	for (i, a) in enumerate(a1s[::-1], 1):
		m = min(m, a)
		min1s[-i] = m
	min1s[0] = m
	record = float('inf')
	for i in range(n):
		d = cum0s[i] + cum1s[i] + bs[i]
		for j in range(i, n):
			dist = d + cum0s[j] + cum1s[j] + bs[j]
			if i == j:
				continue
			if dist < record:
				record = dist
	return record
print(solve(n, a0s, a1s, bs))


from typing import List

def get_least_total(n, row_1: List[int], row_2: List[int], cross: List[int]):
	current_distance = cross[0] + sum(row_2)
	distances = [current_distance]
	for i in range(1, n):
		current_distance -= row_2[i - 1]
		current_distance -= cross[i - 1]
		current_distance += row_1[i - 1]
		current_distance += cross[i]
		distances.append(current_distance)
	distances = sorted(distances)
	return distances[0] + distances[1]
n = int(input())
row1 = [int(i) for i in input().split()]
row2 = [int(i) for i in input().split()]
cross_prices = [int(i) for i in input().split()]
print(get_least_total(n, row1, row2, cross_prices))


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
cost = [[0], [0]]
for i in range(N - 1):
	cost[0].append(cost[0][i] + A[i])
	cost[1].append(cost[1][i] + B[N - 2 - i])
cost[1].reverse()
min_cost = 99999999999
min_i = -1
for i in range(N):
	if min_cost > cost[0][i] + cost[1][i] + C[i]:
		min_cost = cost[0][i] + cost[1][i] + C[i]
		min_i = i
min_cost2 = 99999999999
for i in range(N):
	if min_cost2 > cost[0][i] + cost[1][i] + C[i] and i != min_i:
		min_cost2 = cost[0][i] + cost[1][i] + C[i]
print(min_cost + min_cost2)


n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
b = list(map(int, input().split()))
res = []
for index in range(len(b)):
	res.append(b[index] + sum(a1[:index]) + sum(a2[index:]))
res.sort()
print(res[0] + res[1])


def traverse(street):
	a = sum(street[0])
	b = sum(street[1])
	(paths, d, e) = ([a + street[2][-1], b + street[2][0]], 0, 0)
	for s in range(length - 2, 0, -1):
		d += street[0][s]
		e += street[1][s]
		p = a - d + e + street[2][s]
		paths.append(p)
	(f, s) = (1000000, 1000000)
	for p in paths:
		if p < f:
			s = f
			f = p
		elif p < s:
			s = p
	return f + s
length = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
street = [a, b, c]
print(traverse(street))


read = lambda : list(map(int, input().split()))
n = int(input())
(a1, a2, b) = (read(), read(), read())
(prv, suf) = ([0] * n, [0] * n)
suf[-1] = prv[0] = 0
now = 0
for i in range(1, n):
	now += a1[i - 1]
	prv[i] = now
now = 0
for i in range(n - 2, -1, -1):
	now += a2[i]
	suf[i] = now
c = [0] * n
for i in range(n):
	c[i] = prv[i] + b[i] + suf[i]
p1 = min(c)
c[c.index(p1)] = 10 ** 10
p2 = min(c)
ans = p1 + p2
print(ans)


res = []
n = int(input())
a = list(map(int, input().split()))
c = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(n):
	res.append(sum(c[n - 1 - i:]) + b[n - i - 1] + sum(a[:n - 1 - i]))
res.sort()
print(res[0] + res[1])


__author__ = 'pxy'
n = int(input())
ai = [int(i) for i in input().split()]
ai.append(0)
bi = [int(i) for i in input().split()]
bi.append(0)
c = [int(i) for i in input().split()]
gp = 10000000000
gr = 99999999999
for i in range(n):
	if gr > sum(ai[0:i]) + c[i] + sum(bi[i:n - 1]):
		t = gr
		gp = t
		gr = sum(ai[0:i]) + c[i] + sum(bi[i:n - 1])
	elif gp > sum(ai[0:i]) + c[i] + sum(bi[i:n - 1]):
		gp = sum(ai[0:i]) + c[i] + sum(bi[i:n - 1])
print(gp + gr)


n = int(input())
top = list(map(int, input().split()))
bottom = list(map(int, input().split()))
center = list(map(int, input().split()))
answers = []

def findSum(start, end, line):
	global top, bottom
	s = 0
	if line == 1:
		for i in range(end, start):
			s += bottom[i]
	else:
		for i in range(end, start):
			s += top[i]
	return s
for i in range(n):
	answers.append(center[n - i - 1] + findSum(n - 1, n - i - 1, 1) + findSum(n - i - 1, 0, 0))
answers.sort()
print(answers[0] + answers[1])


import itertools as it
import functools
import operator
import collections
import math
import sys

def dist(up_adj, down_adj, i):
	assert len(up_adj) == len(down_adj)
	assert 0 <= i <= len(up_adj)
	return sum(up_adj[:i]) + sum(down_adj[i:])

def solve(up_adj, down_adj, up_down):
	distances = sorted((dist(up_adj, down_adj, i) + ud for (i, ud) in enumerate(up_down)))
	return distances[0] + distances[1]

def main():
	n = int(input())
	xs = [int(i) for i in input().strip().split()]
	ys = [int(i) for i in input().strip().split()]
	zs = [int(i) for i in input().strip().split()]
	assert len(xs) == len(ys) == n - 1
	assert len(zs) == n
	result = solve(xs, ys, zs)
	print(result)
main()


import sys
n = int(input())
v1 = list(map(int, ('0 ' + input()).split()))
v2 = list(map(int, (input() + ' 0').split()))
v3 = list(map(int, input().split()))
for i in range(1, n):
	v1[i] = v1[i] + v1[i - 1]
for i in range(n - 2, -1, -1):
	v2[i] = v2[i] + v2[i + 1]
for i in range(0, n):
	v3[i] += v1[i] + v2[i]
v3.sort()
print(v3[0] + v3[1])


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
s = [int(x) for x in input().split()]
p1 = [0]
for i in range(n - 1):
	p1.append(p1[-1] + a[i])
p2 = [0]
for i in range(n - 1):
	p2.append(p2[-1] + b[-i - 1])
min1 = 10000000
min2 = 10000000
for i in range(n):
	summ = p1[i] + p2[n - i - 1] + s[i]
	if summ < min1:
		min2 = min1
		min1 = summ
	elif summ < min2:
		min2 = summ
print(min1 + min2)


import os
import sys
import random
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
tot = 0
min2 = 1000000000
for i in range(0, n - 1):
	tot += b[i]
temp = list(map(int, input().split()))
tot += temp[0]
min1 = tot
for i in range(1, n):
	tot -= temp[i - 1]
	tot -= b[i - 1]
	tot += temp[i]
	tot += a[i - 1]
	if tot <= min1:
		min2 = min1
		min1 = tot
	elif tot < min2:
		min2 = tot
min1 += min2
print(min1)


n = int(input())
ar1 = list(map(int, input().split()))
ar2 = list(map(int, input().split()))
br = list(map(int, input().split()))
pre = [0] * (n + 1)
for i in range(n - 1):
	pre[i + 1] = ar1[i] + pre[i]
suf = ar2
suf.append(0)
suf.append(0)
for i in range(n - 1, -1, -1):
	suf[i] += suf[i + 1]
an = []
for i in range(n):
	an.append(suf[i] + pre[i] + br[i])
an.sort()
print(an[0] + an[1])


n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = None
topBottom = sum(a2)
for i in range(n):
	bottomTop = sum(a2)
	for j in range(n):
		if j != i:
			cur = topBottom + b[i] + bottomTop + b[j]
			ans = cur if ans == None else min(ans, cur)
		if j < n - 1:
			bottomTop = bottomTop + a1[j] - a2[j]
	if i < n - 1:
		topBottom = topBottom + a1[i] - a2[i]
print(ans)


n = int(input())
shop_row = [0] + list(map(int, input().split()))
house_row = list(map(int, input().split())) + [0]
perek = list(map(int, input().split()))
for i in range(len(house_row) - 2, -1, -1):
	house_row[i] += house_row[i + 1]
for i in range(1, len(shop_row)):
	shop_row[i] += shop_row[i - 1]
rez = [None] * n
for i in range(n):
	rez[i] = house_row[i] + shop_row[i] + perek[i]
rez.sort()
if len(rez) > 1:
	print(rez[0] + rez[1])
else:
	print(rez[0] + rez[0])


v = int(input())
row1Line = input()
row2Line = input()
inRowLine = input()
row1 = row1Line.split()
row2 = row2Line.split()
inRow = inRowLine.split()
row1 = [int(row1[i]) for i in range(v - 1)]
row2 = [int(row2[i]) for i in range(v - 1)]
inRow = [int(inRow[i]) for i in range(v)]
ansList = []
for i in range(v):
	a = 0
	for j in range(i):
		a += row1[j]
	a += inRow[i]
	for j in range(i, v - 1):
		a += row2[j]
	ansList.append(a)
ansList.sort()
print(ansList[0] + ansList[1])


n = int(input())
H1 = list(map(int, input().split()))
H2 = list(map(int, input().split()))
av = list(map(int, input().split()))
ans = []
for i in range(n - 1):
	ans.append(sum(H1[:i]) + av[i] + sum(H2[i:]))
ans.append(sum(H1) + av[-1])
ans.sort()
print(ans[0] + ans[1])


n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
b = list(map(int, input().split()))
cc1 = [0 for _ in range(n)]
cc2 = [0 for _ in range(n)]
cd1 = [0 for _ in range(n)]
cd2 = [0 for _ in range(n)]
cc1[0] = 0
cc1[1] = a1[0]
for k in range(2, n):
	cc1[k] = a1[k - 1] + cc1[k - 1]
cd2[n - 1] = 0
cd2[n - 2] = a2[n - 2]
for k in range(n - 3, -1, -1):
	cd2[k] = a2[k] + cd2[k + 1]
r1 = max(b) + max(cc1) + max(cd2)
d = 0
r2 = max(b) + max(cc1) + max(cd2)
for k in range(n):
	if cd2[k] + b[k] + cc1[k] < r1:
		r1 = cd2[k] + b[k] + cc1[k]
		d = k
for k in range(n):
	if cc1[k] + b[k] + cd2[k] < r2 and d != k:
		r2 = cc1[k] + b[k] + cd2[k]
print(r1 + r2)


n = int(input()) - 1

def d():
	return list(map(int, input().split()))
a = d()
b = d()
c = d()
v = []
while n >= 0:
	v.append(sum(a[:n]) + c[n] + sum(b[n:]))
	n -= 1
v.sort()
print(v[0] + v[1])


n = int(input())
a = []
for _ in range(2):
	a.append(list(map(int, input().split())))
b = list(map(int, input().split()))
ans = []
for (i, e) in enumerate(b):
	ans.append(e + sum(a[0][:i]) + sum(a[1][i:]))
print(sum(sorted(ans)[0:2]))


from sys import stdin
n = stdin.readline().rstrip()
n = int(n)
first_row = [int(i) for i in stdin.readline().rstrip().split()]
second_row = [int(i) for i in stdin.readline().rstrip().split()]
main_crossing = [int(i) for i in stdin.readline().rstrip().split()]
min_1 = float('inf')
min_2 = float('inf')
for i in range(n):
	first_row_time = sum(first_row[:i])
	second_row_time = sum(second_row[i:])
	trip_time = first_row_time + second_row_time + main_crossing[i]
	if trip_time < min_1:
		(min_1, min_2) = (trip_time, min_1)
	elif trip_time < min_2:
		min_2 = trip_time
print(min_1 + min_2)


n = int(input())
a1 = [int(v) for v in input().split()]
a2 = [int(v) for v in input().split()]
b = [int(v) for v in input().split()]

def make_prefixes(a):
	pref = [0, a[0]]
	for v in a[1:]:
		pref.append(pref[-1] + v)
	return pref
prefa1 = make_prefixes(a1)
prefa2 = make_prefixes(a2)
crosstimes = [prefa1[i] + b[i] + (prefa2[-1] - prefa2[i]) for i in range(n)]
crosstimes.sort()
print(crosstimes[0] + crosstimes[1])


def solve(start, end, a, b, cross, cost):
	global arr
	if start == end:
		arr.append(cost)
		return
	(x, y) = start
	if x == 0 and y < n - 1:
		solve((x, y + 1), end, a, b, cross, cost + a[y])
		solve((x + 1, y), end, a, b, cross, cost + cross[y])
	elif x == 0 and y == n - 1:
		solve((x + 1, y), end, a, b, cross, cost + cross[y])
	elif x == 1:
		solve((x, y + 1), end, a, b, cross, cost + b[y])
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cross = list(map(int, input().split()))
arr = []
solve((0, 0), (1, n - 1), a, b, cross, 0)
arr.sort()
print(arr[0] + arr[1])


n = int(input())
a = [[], []]
a[0] = list(map(int, input().split()))
a[1] = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = float('+inf')
for i in range(n):
	for j in range(n):
		if i == j:
			continue
		cur = sum(a[1][i:]) + sum(a[0][:i]) + sum(a[0][:j]) + sum(a[1][j:]) + b[i] + b[j]
		ans = min(ans, cur)
print(ans)


n = int(input())
f = [0] + list(map(int, input().split()))
s = list(map(int, input().split())) + [0]
a = list(map(int, input().split()))
l = sorted([sum(f[:i + 1]) + a[i] + sum(s[i:]) for i in range(n)])
print(l[0] + l[1])


n = int(input())
first = list(map(int, input().split()))
second = list(map(int, input().split()))
main = list(map(int, input().split()))
sums = [0] * n
for i in range(n - 1):
	sums[i] = sum(first[:i]) + main[i] + sum(second[i:])
sums[n - 1] = main[n - 1] + sum(first)
firstmin = min(sums)
sums.remove(firstmin)
secmin = min(sums)
print(firstmin + secmin)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = []
s_a = sum(a)
s_b = sum(b)
s = 0
d.append(c[0] + s_b)
for i in range(n - 1):
	s += a[i]
	s_b -= b[i]
	d.append(s + c[i + 1] + s_b)
d.sort()
print(d[0] + d[1])


def main():
	input()
	(a, b, c) = (list(map(int, input().split())) for _ in 'abc')
	(u, res) = (sum(b), [])
	for (x, y, z) in zip(a, b, c):
		res.append(u + z)
		u += x - y
	res.append(u + c[-1])
	print(sum(sorted(res)[:2]))
main()


n = int(input())
top = [0]
bot = [0]
top += [int(i) for i in input().split()]
bot += [int(i) for i in input().split()]
cross = [int(i) for i in input().split()]
for i in range(1, n):
	top[i] += top[i - 1]
	bot[i] += bot[i - 1]
best = 11111111111111
best2 = 11111111111111
for i in range(n):
	dist = top[i] + cross[i] + (bot[n - 1] - bot[i])
	if dist < best2:
		if dist <= best:
			best2 = best
			best = dist
		else:
			best2 = dist
print(best + best2)


n = int(input())
a = [list(map(int, input().split())) for i in range(2)]
b = list(map(int, input().split()))
d = 0
min_d = []
for i in range(n):
	for j in range(0, i):
		d += a[0][j]
	for k in range(i, n - 1):
		d += a[1][k]
	d += b[i]
	min_d.append(d)
	d = 0
min_d.sort()
suma = min_d[0] + min_d[1]
print(suma)


n = int(input())
a1 = [int(s) for s in input().split()]
a2 = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]
sum = 0
for i in range(n - 1):
	sum = sum + a2[i]
sum1 = min(sum + b[0], sum - a2[0] + a1[0] + b[1])
sum2 = max(sum + b[0], sum - a2[0] + a1[0] + b[1])
sum = sum - a2[0] + a1[0] + b[1]
for i in range(2, n):
	sum = sum + b[i] - b[i - 1] + a1[i - 1] - a2[i - 1]
	if sum < sum1:
		sum2 = min(sum2, sum1)
		sum1 = sum
	else:
		sum2 = min(sum2, sum)
print(sum1 + sum2)


n = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
B = list(map(int, input().split()))
dist1 = 10 ** 8
dist2 = 10 ** 8
for i in range(n):
	dist = sum(A1[0:i] + A2[i:n]) + B[i]
	if dist < dist1:
		dist2 = min(dist2, dist1)
		dist1 = dist
	elif dist < dist2:
		dist2 = dist
print(dist1 + dist2)


n = int(input())
b1 = list(map(int, input().split()))
b2 = list(map(int, input().split()))
b3 = list(map(int, input().split()))
ans = []
n -= 1
while n >= 0:
	ans.append(sum(b1[:n]) + b3[n] + sum(b2[n:]))
	n -= 1
ans.sort()
print(ans[0] + ans[1])


from collections import Counter

def mp():
	return map(int, input().split())

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)
n = it()
L1 = lt()
L2 = lt()
cross = lt()
s = sum(L2)
L = sorted([sum(L1[:i]) + sum(L2[i:]) + cross[i] for i in range(n)])
print(L[0] + L[1])


def s():
	n = int(input())
	a = [0]
	a.extend(map(int, input().split()))
	b = list(map(int, input().split()))
	b.append(0)
	c = list(map(int, input().split()))
	for i in range(n - 2, -1, -1):
		b[i] += b[i + 1]
	for i in range(2, n):
		a[i] += a[i - 1]
	r = 3 * [a[-1] + b[0] + 101]
	for i in range(n):
		r[-1] = a[i] + b[i] + c[i]
		r.sort()
	print(sum(r[0:2]))
s()


n = int(input())
b = []
b.append([int(i) for i in input().split()])
b.append([int(i) for i in input().split()])
a = [int(i) for i in input().split()]
b1s = [0]
b2s = [0]
for i in range(n - 1):
	b1s.append(b[0][i])
	b1s[i + 1] += b1s[i]
	b2s.insert(0, b[1][n - i - 2])
	b2s[0] += b2s[1]
m = 10000000000.0
for i in range(n):
	for j in range(n):
		if i == j:
			continue
		c = a[i] + a[j] + b1s[i] + b1s[j] + b2s[i] + b2s[j]
		m = min(m, c)
print(m)


n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
cr = list(map(int, input().split(' ')))
val = []
for i in range(n):
	val.append(sum(a[0:i]) + cr[i] + sum(b[i:]))
val.sort()
print(val[0] + val[1])


def calc(i, one, two, cross):
	return cross[i] + sum(one[:i]) + sum(two[i:])
n = int(input())
one = list(map(int, input().split()))
two = list(map(int, input().split()))
cross = list(map(int, input().split()))
first = 10000000
sec = 10000000
for i in range(n):
	x = calc(i, one, two, cross)
	if x < first:
		temp = first
		first = x
		sec = temp
	elif x < sec:
		sec = x
print(first + sec)


n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
k = 0
for i in range(2):
	c.append([0] * n)
c[1][0] = b[0]
for i in range(1, n):
	c[0][i] = c[0][i - 1] + a1[i - 1]
	if c[1][i - 1] + a2[i - 1] > c[0][i] + b[i]:
		k = i
	c[1][i] = min(c[1][i - 1] + a2[i - 1], c[0][i] + b[i])
ans = 0
ans += c[-1][-1]
b[k] = 1000
c = []
for i in range(2):
	c.append([0] * n)
c[1][0] = b[0]
for i in range(1, n):
	c[0][i] = c[0][i - 1] + a1[i - 1]
	c[1][i] = min(c[1][i - 1] + a2[i - 1], c[0][i] + b[i])
ans += c[-1][-1]
print(ans)


n = int(input())
row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))
vert = list(map(int, input().split()))
lo = float('inf')
res = 0
firstcross = 0
secondcross = 0
for i in range(n):
	cur = vert[i]
	cur += sum(row2[i:])
	cur += sum(row1[:i])
	if cur < lo:
		firstcross = i
		lo = cur
res += lo
lo = float('inf')
for i in range(n):
	cur = vert[i]
	for j in range(i):
		cur += row1[j]
	for j in range(i, n - 1):
		cur += row2[j]
	if cur < lo and i != firstcross:
		lo = cur
		secondcross = i
res += lo
print(res)


from sys import stdin, stdout
import copy
input = stdin.readline
n = int(input())
a = [None, None]
a[0] = list(map(int, input().split()))
a[1] = list(map(int, input().split()))
b = list(map(int, input().split()))
p = [[None for _ in range(n)] for i in range(2)]
dp = [[0 for _ in range(n)] for i in range(2)]
for i in range(1, n):
	dp[0][i] = dp[0][i - 1] + a[0][i - 1]
	p[0][i] = (0, i - 1)
dp[1][0] = dp[0][0] + b[0]
p[1][0] = (0, 0)
for i in range(1, n):
	if dp[1][i - 1] + a[1][i - 1] < dp[0][i] + b[i]:
		dp[1][i] = dp[1][i - 1] + a[1][i - 1]
		p[1][i] = (1, i - 1)
	else:
		dp[1][i] = dp[0][i] + b[i]
		p[1][i] = (0, i)
forbiden = [(1, n - 1)]
par = p[1][n - 1]
while par:
	forbiden.append(par)
	par = p[par[0]][par[1]]

def solve(a, b, fr, to):
	dp = [[0 for _ in range(n)] for i in range(2)]
	if fr[0] == to[0]:
		a[fr[0]][fr[1]] = 1000000000
	else:
		b[fr[1]] = 10000000
	dp = [[0 for _ in range(n)] for i in range(2)]
	for i in range(1, n):
		dp[0][i] = dp[0][i - 1] + a[0][i - 1]
	dp[1][0] = dp[0][0] + b[0]
	for i in range(1, n):
		dp[1][i] = min(dp[1][i - 1] + a[1][i - 1], dp[0][i] + b[i])
	return dp[1][len(b) - 1]
m = 10000000
for i in range(len(forbiden) - 1):
	am = copy.deepcopy(a)
	bm = copy.deepcopy(b)
	m = min(m, solve(am, bm, forbiden[i + 1], forbiden[i]))
stdout.write(str(dp[1][n - 1] + m))


n = int(input())
a2 = input().split()
a2 = [int(a) for a in a2]
a1 = input().split()
a1 = [int(a) for a in a1]
b = input().split()
b = [int(a) for a in b]
timea1 = [0]
sum = 0
for i in reversed(a1):
	sum += i
	timea1[:0] = [sum]
timea2 = [0]
sum = 0
for i in a2:
	sum += i
	timea2.append(sum)
min1 = 100000000000
min2 = 100000000000
k = 0

def time(i):
	return timea1[i] + b[i] + timea2[i]
for i in range(0, n):
	t = time(i)
	if t < min1:
		min1 = t
		k = i
for i in range(0, n):
	t = time(i)
	if t < min2 and i != k:
		min2 = t
print(min1 + min2)


n = int(input())
a = [0] + [int(x) for x in input().split()]
b = [int(x) for x in input().split()] + [0]
c = [int(x) for x in input().split()]
for i in range(1, n):
	a[i] += a[i - 1]
	b[n - 1 - i] += b[n - i]
d = []
for i in range(n):
	d.append(a[i] + b[i] + c[i])
d.sort()
print(d[0] + d[1])


I = lambda : list(map(int, input().split()))
R = range(I()[0])
a = I()
b = I()
c = I()
print(min((c[i] + c[j] + sum(a[:i] + a[:j] + b[i:] + b[j:]) for i in R for j in R if i != j)))


a = int(input())
z = [[0] + list(map(int, input().split())), [0] + list(map(int, input().split()))]
r = [0] + list(map(int, input().split()))
k = []
for i in range(a, 0, -1):
	k.insert(0, sum(z[0][:i]) + r[i] + sum(z[1][i:]))
s = min(k)
k[k.index(s)] = 2 * a * 100
print(s + min(k))


n = int(input())
l = list(map(int, input().split()))
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
f = sum(l1) + l2[0]
e = [f]
for i in range(n - 1):
	f += -l2[i] - l1[i] + l2[i + 1] + l[i]
	e.append(f)
e = sorted(e)
print(e[0] + e[1])


n = int(input())
line1 = list(map(int, input().split()))
line2 = list(map(int, input().split()))
line3 = list(map(int, input().split()))
distanceList = [line3[0] + sum(line2)]
for i in range(1, n - 1):
	distanceList.append(sum(line1[:i]) + sum(line2[i - n + 1:]) + line3[i])
distanceList.append(line3[n - 1] + sum(line1))
distanceList.sort()
print(distanceList[0] + distanceList[1])


from sys import stdin

def traverse(street):
	a = sum(street[0])
	b = sum(street[1])
	(paths, d, e) = ([a + street[2][-1], b + street[2][0]], 0, 0)
	for s in range(length - 2, 0, -1):
		d += street[0][s]
		e += street[1][s]
		p = a - d + e + street[2][s]
		paths.append(p)
	(f, s) = (1000000, 1000000)
	for p in paths:
		if p < f:
			s = f
			f = p
		elif p < s:
			s = p
	return f + s
ins = stdin.readlines()
length = int(ins[0])
a = list(map(int, ins[1].split()))
b = list(map(int, ins[2].split()))
c = list(map(int, ins[3].split()))
street = [a, b, c]
print(traverse(street))


n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
b = list(map(int, input().split()))
pref1 = [0] * n
for i in range(1, n):
	pref1[i] = pref1[i - 1] + a1[i - 1]
pref2 = [0] * n
for i in range(1, n):
	pref2[i] = pref2[i - 1] + a2[i - 1]
post2 = [sum(a2)] * n
for i in range(n):
	post2[i] -= pref2[i]
minimum = -1
for i in range(n):
	for j in range(n):
		if j != i:
			if minimum == -1:
				minimum = pref1[i] + post2[i] + b[i] + pref1[j] + post2[j] + b[j]
			else:
				minimum = min(pref1[i] + post2[i] + b[i] + pref1[j] + post2[j] + b[j], minimum)
print(minimum)


read = lambda : list(map(int, input().split()))
N = int(input())
(fr, sr, cross) = (read(), read(), read())
spend_time = [sum(sr) + cross[0]]
for i in range(1, N):
	summ = spend_time[-1] - sr[i - 1] - cross[i - 1]
	summ = summ + fr[i - 1] + cross[i]
	spend_time.append(summ)
spend_time.sort()
print(spend_time[0] + spend_time[1])


from sys import stdin
n = int(stdin.readline())
a1 = [int(x) for x in stdin.readline().split()]
a2 = [int(x) for x in stdin.readline().split()]
b = [int(x) for x in stdin.readline().split()]
cum1 = a1[:]
cum2 = a2[:]
for i in range(1, n - 1):
	cum1[i] += cum1[i - 1]
for i in range(n - 3, -1, -1):
	cum2[i] += cum2[i + 1]
(min1, min2) = (1000000, 1000000)
for i in range(n):
	c = b[i]
	if i:
		c += cum1[i - 1]
	if i < n - 1:
		c += cum2[i]
	if c <= min1:
		min2 = min1
		min1 = c
	elif c < min2:
		min2 = c
print(min1 + min2)


def main():
	n = int(input())
	a = [[0 for i in range(n - 1)] for j in range(2)]
	for i in range(2):
		a[i] = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = 0
	mini = []
	for i in range(n - 1):
		s += a[1][i]
	s += b[0]
	mini.append(s)
	for i in range(1, n):
		s -= b[i - 1]
		s += b[i]
		s -= a[1][i - 1]
		s += a[0][i - 1]
		mini.append(s)
	mini.sort()
	print(mini[0] + mini[1])
main()


import time
import math

def func(a, b, flag):
	s = b[0] + sum(a[1])
	if flag == 0:
		s += a[0][0] - a[1][0] + b[1] - b[0]
		min_s = s
		min_p = 1
	else:
		s = b[0] + sum(a[1])
		min_s = s
		min_p = 0
	for now in range(1, n):
		s += a[0][now - 1] - a[1][now - 1] + b[now] - b[now - 1]
		if flag == now:
			continue
		if s < min_s:
			min_s = s
			min_p = now
	return (min_s, min_p)
n = int(input())
a = [0, 0]
a[0] = [int(i) for i in input().split()]
a[1] = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
start = time.time()
(s1, p) = func(a, b, -1)
(s2, p) = func(a, b, p)
print(s1 + s2)
finish = time.time()


n = int(input())
A1 = [int(a) for a in input().strip().split(' ')]
A2 = [int(a) for a in input().strip().split(' ')]
A = [A1, A2]
B = [int(a) for a in input().strip().split(' ')]
res = []
for i in range(len(B)):
	s = B[i] + sum(A[0][:i]) + sum(A[1][i:])
	res.append(s)
res.sort()
s = res[0] + res[1]
print(s)


n = int(input())
up = [int(item) for item in input().split()]
down = [int(item) for item in input().split()]
j = [int(item) for item in input().split()]
time = 0
mas = []
for idx in range(n - 1, -1, -1):
	mas.append(j[idx] + sum([n for n in up[0:idx]]) + sum([n for n in down[idx:]]))
mas.sort()
print(mas[0] + mas[1])


from functools import lru_cache, wraps
from sys import stderr
import time
INF = 10 ** 18 + 3
EPS = 1e-10

def print_to_file(function, file=stderr):

	def wrapped(*args, **kwargs):
		res = function(*args, **kwargs)
		print(res, file=file)
		return res
	return wrapped

def time_it(function, output=stderr):

	def wrapped(*args, **kwargs):
		start = time.time()
		res = function(*args, **kwargs)
		elapsed_time = time.time() - start
		print('Function "%s" took %f ms' % (function.__name__, elapsed_time * 1000), file=output)
		return res
	return wrapped

@time_it
def main():
	n = int(input())
	rows1 = tuple(map(int, input().split()))
	rows2 = tuple(map(int, input().split()))
	cols = tuple(map(int, input().split()))
	times = sorted((sum(rows1[:i]) + cols[i] + sum(rows2[i:]) for i in range(n)))
	print(times[0] + times[1])

@lru_cache(10 ** 9)
def find_perm(length, n_different):
	if length == 0:
		return []
	if n_different != length - 1:
		return list(range_of_len(length, length - n_different - 1, -1)) + find_perm(n_different + 1, n_different)
	curr = length
	go_down = True
	res = []
	for _ in range(n_different + 1):
		res.append(curr)
		curr = length - curr + go_down
		go_down ^= True
	return res

@print_to_file
def range_of_len(start, length, step=1):
	return range(start, start + length * step, step)

def set_input(file):
	global input
	input = lambda : file.readline().strip()

def set_output(file):
	global print
	l_print = print

	def print(*args, **kwargs):
		kwargs['file'] = kwargs.get('file', file)
		return l_print(*args, **kwargs)
main()


n = int(input())
a = [[], [0], [0]]
b = [0]
ans = 1000000000.0
a[1].extend([int(v) for v in input().split(' ')])
a[2].extend([int(v) for v in input().split(' ')])
b.extend([int(v) for v in input().split(' ')])
for i in range(1, n):
	a[1][i] += a[1][i - 1]
for i in range(n - 2, 0, -1):
	a[2][i] += a[2][i + 1]
(a[1].append(0), a[2].append(0))
for i in range(1, n + 1):
	for j in range(1, n + 1):
		if i != j:
			ans = min(ans, a[1][i - 1] + b[i] + a[2][i] + a[1][j - 1] + b[j] + a[2][j])
print(ans)


N = int(input())
(fr, sr) = ([int(i) for i in input().split()], [int(i) for i in input().split()])
cross = [int(i) for i in input().split()]
spend_time = [sum(sr) + cross[0]]
for i in range(1, N):
	summ = spend_time[-1] - sr[i - 1] - cross[i - 1]
	summ = summ + fr[i - 1] + cross[i]
	spend_time.append(summ)
spend_time.sort()
print(spend_time[0] + spend_time[1])


def solve(a, b):
	pth = []
	s = 0
	for i in range(0, len(b), 1):
		for j in range(0, i, 1):
			s += int(a[0][j])
		s += int(b[i])
		for j in range(i, len(b) - 1, 1):
			s += int(a[1][j])
		pth.append(s)
		s = 0
	pth.sort()
	return pth[0] + pth[1]
inp1 = []
fininp1 = []
inp0 = input()
inp1.append(input())
inp1.append(input())
inp2 = input()
fininp1.append(inp1[0].split())
fininp1.append(inp1[1].split())
fininp2 = inp2.split()
print(solve(fininp1, fininp2))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = [0] * n
e = [0] * n
for i in range(1, n):
	d[i] = d[i - 1] + a[i - 1]
for i in range(n - 2, -1, -1):
	e[i] = e[i + 1] + b[i]
x = y = int(1000000000.0)
for i in range(n):
	t = d[i] + e[i] + c[i]
	if t < y:
		if t < x:
			(x, y) = (t, x)
		else:
			y = t
print(x + y)


n = int(input())
a1 = [int(i) for i in input().split(' ')]
a2 = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]
res = 1111111111111
for i in range(0, n):
	for j in range(i + 1, n):
		tmp = b[i] + b[j] + sum(a1[:i]) + sum(a2[i:]) + sum(a1[:j]) + sum(a2[j:])
		if tmp < res:
			res = tmp
print(res)


def f(i):
	return sum(a1[0:i]) + sum(a2[i:]) + b[i]
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
b = list(map(int, input().split()))
m1 = 0
m2 = 1
if f(m1) > f(m2):
	(m1, m2) = (m2, m1)
for i in range(2, n):
	if f(i) < f(m1):
		(m1, m2) = (i, m1)
	elif f(i) < f(m2):
		m2 = i
print(f(m1) + f(m2))


n = int(input())
a1 = input().split()
a2 = input().split()
b = input().split()
a1.insert(0, 0)
a2.insert(n - 1, 0)
(k1, k2) = (0, 0)
for i in range(n):
	k1 += int(a1[i])
	a1[i] = k1
	k2 += int(a2[n - i - 1])
	a2[n - 1 - i] = k2
	b[i] = int(b[i])
l = []
for i in range(n):
	l.append(a1[i] + b[i] + a2[i])
l.sort()
print(l[0] + l[1])


from sys import stdin
n = stdin.readline().rstrip()
n = int(n)
first_row = [int(i) for i in stdin.readline().rstrip().split()]
second_row = [int(i) for i in stdin.readline().rstrip().split()]
main_crossing = [int(i) for i in stdin.readline().rstrip().split()]
min_1 = float('inf')
min_2 = float('inf')
trip_times = []
for i in range(n):
	first_row_time = sum(first_row[:i])
	second_row_time = sum(second_row[i:])
	trip_time = first_row_time + second_row_time + main_crossing[i]
	trip_times.append(trip_time)
trip_times.sort()
print(trip_times[0] + trip_times[1])


n = int(input())
a = [0] + [int(x) for x in input().split()]
b = [int(x) for x in input().split()] + [0]
c = [int(x) for x in input().split()]
for i in range(1, n):
	a[i] += a[i - 1]
	b[n - i - 1] += b[n - i]
l = [0] * n
for i in range(n):
	l[i] = a[i] + b[i] + c[i]
l.sort()
print(l[0] + l[1])


n = int(input())
a = [None, None]
a[0] = list(map(int, input().split()))
a[1] = list(map(int, input().split()))
b = list(map(int, input().split()))
d = []
for p in range(n):
	d.append(sum(a[0][:p]) + b[p] + sum(a[1][p:]))
print(sum(sorted(d)[:2]))


n = int(input())
at = [0] + list(map(int, input().split()))
for i in range(1, n):
	at[i] += at[i - 1]
ab = list(map(int, input().split())) + [0]
for i in range(n - 2, -1, -1):
	ab[i] += ab[i + 1]
b = list(map(int, input().split()))
v = sorted((at[i] + ab[i] + b[i] for i in range(n)))
print(v[0] + v[1])


n = int(input())
top = list(map(int, input().split()))
bottom = list(map(int, input().split()))
center = list(map(int, input().split()))
answers = []

def findSum(start, end, arr):
	ss = 0
	if arr == 'bot':
		for i in range(end, start):
			ss += bottom[i]
	else:
		for i in range(end, start):
			ss += top[i]
	return ss
for i in range(n):
	sum = 0
	sum += center[n - i - 1]
	sum += findSum(n - 1, n - i - 1, 'bot')
	sum += findSum(n - i - 1, 0, 'top')
	answers.append(sum)
answers.sort()
print(answers[0] + answers[1])