Finally, a basketball court has been opened in SIS, so Demid has decided to hold a basketball exercise session. $2 \cdot n$ students have come to Demid's exercise session, and he lined up them into two rows of the same size (there are exactly $n$ people in each row). Students are numbered from $1$ to $n$ in each row in order from left to right.

 [Image] 

Now Demid wants to choose a team to play basketball. He will choose players from left to right, and the index of each chosen player (excluding the first one taken) will be strictly greater than the index of the previously chosen player. To avoid giving preference to one of the rows, Demid chooses students in such a way that no consecutive chosen students belong to the same row. The first student can be chosen among all $2n$ students (there are no additional constraints), and a team can consist of any number of students. 

Demid thinks, that in order to compose a perfect team, he should choose students in such a way, that the total height of all chosen students is maximum possible. Help Demid to find the maximum possible total height of players in a team he can choose.


-----Input-----

The first line of the input contains a single integer $n$ ($1 \le n \le 10^5$) — the number of students in each row.

The second line of the input contains $n$ integers $h_{1, 1}, h_{1, 2}, \ldots, h_{1, n}$ ($1 \le h_{1, i} \le 10^9$), where $h_{1, i}$ is the height of the $i$-th student in the first row.

The third line of the input contains $n$ integers $h_{2, 1}, h_{2, 2}, \ldots, h_{2, n}$ ($1 \le h_{2, i} \le 10^9$), where $h_{2, i}$ is the height of the $i$-th student in the second row.


-----Output-----

Print a single integer — the maximum possible total height of players in a team Demid can choose.


-----Examples-----
Input
5
9 3 5 7 3
5 8 1 4 5

Output
29

Input
3
1 2 9
10 1 1

Output
19

Input
1
7
4

Output
7



-----Note-----

In the first example Demid can choose the following team as follows:  [Image] 

In the second example Demid can choose the following team as follows:  [Image]

Source: codeforces | Difficulty: MEDIUM
Tags: Dynamic programming


Solutions:
n = int(input())
L1 = list(map(int, input().split()))
L2 = list(map(int, input().split()))
(a0, b0) = (0, 0)
(a1, b1) = (L1[-1], L2[-1])
for k in range(2, n + 1):
	a = L1[-k] + max(b0, b1)
	b = L2[-k] + max(a0, a1)
	(a1, a0) = (a, a1)
	(b1, b0) = (b, b1)
print(max(a1, b1))


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

def I():
	return int(input())

def LI():
	return [int(i) for i in input().split()]
from collections import defaultdict
d = defaultdict(int)
n = I()
h = LI()
g = LI()
ans = 0
dp = [[0] * 3 for _ in range(n + 1)]
dp[1][0] = 0
dp[1][1] = h[0]
dp[1][2] = g[0]
for i in range(1, n):
	dp[i + 1][0] = max(dp[i][1], dp[i][2])
	dp[i + 1][1] = max(dp[i][0], dp[i][2]) + h[i]
	dp[i + 1][2] = max(dp[i][0], dp[i][1]) + g[i]
ans = max(dp[n])
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if n == 1:
	print(max(a[0], b[0]))
else:
	up_dp = []
	do_dp = []
	up_dp.append(a[0])
	up_dp.append(b[0] + a[1])
	do_dp.append(b[0])
	do_dp.append(a[0] + b[1])
	for i in range(2, n):
		do_dp.append(max(up_dp[i - 2] + b[i], up_dp[i - 1] + b[i]))
		up_dp.append(max(do_dp[i - 2] + a[i], do_dp[i - 1] + a[i]))
	print(max(up_dp[n - 1], do_dp[n - 1]))


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
ans1 = h1[0]
ans2 = h2[0]
for i in range(1, n):
	t1 = max(ans2 + h1[i], ans1)
	t2 = max(ans1 + h2[i], ans2)
	ans1 = t1
	ans2 = t2
print(max(ans1, ans2))


n = int(input())
h = [0, 1]
for i2 in range(2):
	h[i2] = [int(i) for i in input().split()]
a = [[0 for i in range(n)] for i in range(2)]
if n == 1:
	print(max(h[0][0], h[1][0]))
else:
	a[0][0] = h[0][0]
	a[1][0] = h[1][0]
	a[0][1] = h[0][1] + a[1][0]
	a[1][1] = h[1][1] + a[0][0]
	for i in range(2, n):
		a[0][i] = max(h[0][i] + a[1][i - 1], h[0][i] + a[1][i - 2])
		a[1][i] = max(h[1][i] + a[0][i - 1], h[1][i] + a[0][i - 2])
	print(max(a[0][-1], a[1][-1], a[0][-2], a[1][-2]))


_ = int(input())
n = [list(map(int, input().split())), list(map(int, input().split()))]
d = (0, 0)
for i in range(_):
	d = (max(d[0], d[1] + n[0][i]), max(d[1], d[0] + n[1][i]))
print(max(d[0], d[1]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dp1 = [0]
dp2 = [0]
for i in range(n):
	dp1.append(max(dp1[-1], dp2[-1] + a[i]))
	dp2.append(max(dp2[-1], dp1[-2] + b[i]))
print(max(dp1[-1], dp2[-1]))


n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
dp = [[0 for i in range(n)] for j in range(3)]
dp[0][0] = a[0]
dp[1][0] = b[0]
for i in range(1, n):
	dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a[i]
	dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + b[i]
	dp[2][i] = max(dp[1][i - 1], dp[0][i - 1])
print(max(dp[0][n - 1], dp[1][n - 1], dp[2][n - 1]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if n == 1:
	print(max(a[0], b[0]))
else:
	c = [0] * n
	d = [0] * n
	c[0] = a[0]
	d[0] = b[0]
	for i in range(1, n):
		c[i] = max(c[i - 1], d[i - 1] + a[i])
		d[i] = max(d[i - 1], c[i - 1] + b[i])
	print(max(d[n - 1], c[n - 1]))


n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
m1 = [0] * n
m2 = [0] * n
m1[0] = a1[0]
m2[0] = a2[0]
if n != 1:
	m1[1] = m2[0] + a1[1]
	m2[1] = m1[0] + a2[1]
for i in range(2, n):
	m1[i] = max((m2[i - 1] + a1[i], m1[i - 2], m2[i - 2] + a1[i]))
	m2[i] = max((m1[i - 1] + a2[i], m2[i - 2], m1[i - 2] + a2[i]))
print(max(m1[-1], m2[-1]))


n = int(input())
a = input().split(' ')
b = input().split(' ')
for i in range(n):
	a[i] = int(a[i])
	b[i] = int(b[i])
F = [[0, 0]] * n
G = [[0, 0]] * n
(F[0][0], F[0][1]) = (G[0][0], G[0][1]) = (a[0], b[0])
for i in range(1, n):
	F[i][0] = G[i - 1][1] + a[i]
	F[i][1] = G[i - 1][0] + b[i]
	G[i][0] = max(G[i - 1][0], F[i][0])
	G[i][1] = max(G[i - 1][1], F[i][1])
print(max(G[n - 1][0], G[n - 1][1]))


n = int(input())
ar1 = list(map(int, input().split()))
ar2 = list(map(int, input().split()))
dp1 = [0] * n
dp2 = [0] * n
dp1[0] = ar1[0]
dp2[0] = ar2[0]
for i in range(n - 1):
	if i == n - 2:
		dp2[i + 1] = max(dp1[i] + ar2[i + 1], dp2[i + 1])
		dp1[i + 1] = max(dp2[i] + ar1[i + 1], dp1[i + 1])
	else:
		dp2[i + 1] = max(dp1[i] + ar2[i + 1], dp2[i + 1])
		dp1[i + 1] = max(dp2[i] + ar1[i + 1], dp1[i + 1])
		dp2[i + 2] = max(dp1[i] + ar2[i + 2], dp2[i + 2])
		dp1[i + 2] = max(dp2[i] + ar1[i + 2], dp1[i + 2])
print(max(dp1[-1], dp2[-1]))


n = int(input())
h = [list(map(int, input().split())) for i in range(2)]
for i in range(n - 1):
	for t in range(2):
		h[t][i + 1] = max(h[t][i + 1] + h[t ^ 1][i], h[t][i])
print(max(h[0][-1], h[1][-1]))


n = int(input())
h1 = [int(x) for x in input().split()]
h2 = [int(x) for x in input().split()]
(prev_U, prev_D, prev_O) = (0, 0, 0)
(U, D, O) = (0, 0, 0)
for i in range(n):
	prev_U = U
	prev_D = D
	prev_O = O
	if i == 0:
		U = h1[0]
		D = h2[0]
		O = 0
	else:
		U = max(prev_D, prev_O) + h1[i]
		D = max(prev_U, prev_O) + h2[i]
		O = max(prev_U, prev_D, prev_O)
print(max(U, D, O))


n = int(input())
a = input().split()
b = input().split()
table = [[0 for i in range(3)] for j in range(n + 1)]
for i in range(n - 1, -1, -1):
	table[i][0] = max(table[i][0], int(a[i]) + max(table[i + 1][1], table[i + 1][2]))
	table[i][1] = max(table[i][1], int(b[i]) + max(table[i + 1][0], table[i + 1][2]))
	table[i][2] = max(table[i][2], table[i + 1][0], table[i + 1][1], table[i + 1][2])
print(max(table[0]))


R = lambda : map(int, input().split())
n = int(input())
arr = [[], []]
arr[0] = [0] + list(R())
arr[1] = [0] + list(R())
dp = [[0 for i in range(n + 2)] for _ in range(2)]
dp[0][1] = arr[0][1]
dp[1][1] = arr[1][1]
for i in range(2, n + 1):
	dp[0][i] = max(dp[0][i - 2], dp[1][i - 2], dp[1][i - 1]) + arr[0][i]
	dp[1][i] = max(dp[1][i - 2], dp[0][i - 2], dp[0][i - 1]) + arr[1][i]
print(max(dp[0][n], dp[1][n]))


import collections
import math
n = int(input())
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
cache = dict()
cache[n - 1, 'up'] = a[n - 1]
cache[n - 1, 'down'] = b[n - 1]
cache[n - 1, 'without'] = 0
for i in reversed(range(n - 1)):
	cache[i, 'up'] = a[i] + max(cache[i + 1, 'down'], cache[i + 1, 'without'])
	cache[i, 'down'] = b[i] + max(cache[i + 1, 'up'], cache[i + 1, 'without'])
	cache[i, 'without'] = max(cache[i + 1, 'down'], cache[i + 1, 'up'], cache[i + 1, 'without'])
print(max(cache[0, 'down'], cache[0, 'up'], cache[0, 'without']))


I = lambda : int(input())
IL = lambda : list(map(int, input().split()))
IF = lambda : list(map(float, input().split()))
n = I()
A = IL()
B = IL()
S = [A[0], B[0], 0]
for i in range(1, n):
	S = [max(S[1], S[2]) + A[i], max(S[0], S[2]) + B[i], max(S[0], S[1])]
print(max(S))


n = int(input())
ch1 = input()
ch2 = input()
L0 = [int(i) for i in ch1.split()]
L1 = [int(i) for i in ch2.split()]
for i in range(1, n):
	if i == 1:
		L0[1] += L1[0]
		L1[1] += L0[0]
	else:
		L0[i] += max(L1[i - 1], L1[i - 2])
		L1[i] += max(L0[i - 1], L0[i - 2])
print(max(L0[n - 1], L1[n - 1]))


a = int(input())
b = []
c = []
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
dp = [[0 for i in range(a + 1)] for i in range(2)]
for i in range(1, a + 1):
	for j in range(2):
		dp[j][i] = max(dp[1 - j][i - 1] + c[j][i - 1], dp[j][i - 1])
print(max(dp[0][-1], dp[1][-1]))


N = int(input())
a = []
for i in range(2):
	a.append(list(map(int, input().split())))
dp = [[0] * 2 for _ in range(N)]
for i in range(2):
	dp[0][i] = a[i][0]
for i in range(N):
	for j in range(2):
		if i % 2 == 0:
			if i >= 1:
				dp[i][j] = max(dp[i][j], dp[i - 1][j] + a[j][i])
			if i >= 2:
				dp[i][j] = max(dp[i][j], dp[i - 2][1 - j] + a[j][i])
		else:
			if i >= 1:
				dp[i][1 - j] = max(dp[i][1 - j], dp[i - 1][1 - j] + a[j][i])
			if i >= 2:
				dp[i][1 - j] = max(dp[i][1 - j], dp[i - 2][j] + a[j][i])
print(max(dp[N - 1][0], dp[N - 1][1]))


n = int(input())
dp = [[0, 0] for i in range(n)]
a = [int(X) for X in input().split()]
b = [int(x) for x in input().split()]
dp[0] = [a[0], b[0]]
for i in range(1, n):
	dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][0])
	dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][1])
print(max(dp[n - 1]))


n = int(input())
h = [list(map(int, input().split())), list(map(int, input().split()))]
dp = [[0] * n for i in range(2)]
if n == 1:
	print(max(h[0][0], h[1][0]))
else:
	dp[0][0] = h[0][0]
	dp[1][0] = h[1][0]
	dp[0][1] = dp[1][0] + h[0][1]
	dp[1][1] = dp[0][0] + h[1][1]
	for i in range(2, n):
		dp[0][i] = h[0][i] + max(dp[1][i - 1], dp[1][i - 2])
		dp[1][i] = h[1][i] + max(dp[0][i - 1], dp[0][i - 2])
	print(max(dp[0][-1], dp[1][-1]))


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
dp = [[0 for i in range(2)] for j in range(n + 2)]
for i in range(1, n + 1):
	dp[i][0] = max(dp[i - 1][1] + l1[i - 1], dp[i - 1][0])
	dp[i][1] = max(dp[i - 1][0] + l2[i - 1], dp[i - 1][1])
print(max(dp[n][0], dp[n][1]))


I = lambda : map(int, input().split())
(n,) = I()
c = d = 0
for (x, y) in zip(I(), I()):
	(c, d) = (max(d + x, c), max(c + y, d))
print(max(c, d))


def f(a, b, n):
	dpa = [0] * n
	dpb = [0] * n
	dpa[n - 1] = a[n - 1]
	dpb[n - 1] = b[n - 1]
	for i in range(n - 2, -1, -1):
		dpa[i] = max(a[i] + dpb[i + 1], dpa[i + 1])
		dpb[i] = max(b[i] + dpa[i + 1], dpb[i + 1])
	return max(dpa[0], dpb[0])
n = int(input().strip())
a = list(map(int, input().strip().split(' ')))
b = list(map(int, input().strip().split(' ')))
print(f(a, b, n))


n = int(input())
a = input()
A = list(map(int, list(a.split())))
b = input()
B = list(map(int, list(b.split())))
if n > 2:
	dp = [[0 for i in range(n)] for j in range(4)]
	dp[1][0] = A[0]
	dp[2][0] = B[0]
	dp[1][1] = A[1] + dp[2][0]
	dp[2][1] = B[1] + dp[1][0]
	dp[3][1] = max(dp[1][0], dp[2][0])
	for i in range(2, n):
		dp[1][i] = max(dp[2][i - 1] + A[i], dp[3][i - 1] + A[i])
		dp[2][i] = max(dp[1][i - 1] + B[i], dp[3][i - 1] + B[i])
		dp[3][i] = max(dp[1][i - 1], dp[2][i - 1])
	print(max(dp[1][n - 1], dp[2][n - 1]))
elif n == 1:
	print(max(A[0], B[0]))
else:
	print(max(A[0] + B[1], A[1] + B[0]))


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *
getcontext().prec = 25
MOD = pow(10, 9) + 7
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
l = list(map(int, input().split(' ')))
l1 = list(map(int, input().split(' ')))
dp1 = [0] * n
dp2 = [0] * n
dp1[0] = l[0]
dp2[0] = l1[0]
if n > 1:
	dp1[1] += dp2[0] + l[1]
	dp2[1] += dp1[0] + l1[1]
	for i in range(2, n):
		dp1[i] += max(max(dp1[i - 2], dp2[i - 1]), dp2[i - 2]) + l[i]
		dp2[i] += max(max(dp2[i - 2], dp1[i - 1]), dp1[i - 2]) + l1[i]
print(max(dp1[-1], dp2[-1]))


n = int(input())
a = [None] * 3
a[0] = [int(o) for o in input().split()]
a[1] = [int(o) for o in input().split()]
a[2] = [0 for i in range(n)]
dp = [[-float('inf') for i in range(3)] for j in range(n + 1)]
for i in range(n):
	for j in range(3):
		dp[i + 1][j] = max(dp[i][j - 1] + a[j][i], dp[i][j - 2] + a[j][i], a[j][i])
print(max(dp[n]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
f1 = [0] * (n + 3)
f2 = [0] * (n + 3)
f1[1] = a[0]
f2[1] = b[0]
for i in range(1, n):
	f2[i + 1] = max(f2[i], max(f1[i - 1] + b[i], f1[i] + b[i]))
	f1[i + 1] = max(f1[i], max(f2[i - 1] + a[i], f2[i] + a[i]))
print(max(f1[n], f2[n]))


from collections import defaultdict
from math import sqrt
t = 1
for test in range(t):
	n = int(input())
	h1 = list(map(int, input().split()))
	h2 = list(map(int, input().split()))
	dp1 = [0 for i in range(n)]
	dp11 = [0 for i in range(n)]
	dp2 = [0 for i in range(n)]
	dp22 = [0 for i in range(n)]
	dp1[0] = h1[0]
	dp2[0] = h2[0]
	for i in range(1, n):
		dp1[i] = h1[i] + max(dp2[i - 1], dp22[i - 1])
		dp2[i] = h2[i] + max(dp1[i - 1], dp11[i - 1])
		dp11[i] = max(dp1[i - 1], dp11[i - 1])
		dp22[i] = max(dp2[i - 1], dp22[i - 1])
	ans = [dp1[-1], dp2[-1], dp11[-1], dp22[-1]]
	ans.sort()
	print(ans[-1])


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
n = ii1()
a = iia()
b = iia()
x = y = 0
for i in range(n):
	(x, y) = (max(x, y + a[i]), max(y, x + b[i]))
print(max(x, y))


n = int(input())
row1 = list(map(int, input().split())) + [0]
row2 = list(map(int, input().split())) + [0]
row1[1] += row2[0]
row2[1] += row1[0]
for i in range(2, n):
	row1[i] += max(row2[i - 1], row2[i - 2])
	row2[i] += max(row1[i - 1], row1[i - 2])
print(max(row1[n - 1], row2[n - 1]))


n = int(input())
row1 = list(map(int, input().strip().split()))
row2 = list(map(int, input().strip().split()))
row1maxptr = n - 1
row2maxptr = n - 1
for i in range(n - 2, -1, -1):
	row1[i] += row2[row2maxptr]
	row2[i] += row1[row1maxptr]
	if row1[i] > row1[row1maxptr]:
		row1maxptr = i
	if row2[i] > row2[row2maxptr]:
		row2maxptr = i
print(max(row1[0], row2[0]))


n = int(input())
a = []
b = []
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dp = [[0, 0] for _ in range(n)]
for i in range(n):
	if i == 0:
		dp[0][0] = a[0]
		dp[0][1] = b[0]
	else:
		dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][0])
		dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][1])
print(max(dp[n - 1][0], dp[n - 1][1]))


import sys
from collections import deque
IS_LOCAL = False

def read_one(dtype=int):
	return dtype(input())

def read_multiple(f, dtype=int):
	return f(map(dtype, input().split()))

def swap(x, y):
	return (y, x)

def main():
	n = 5
	a = [[9, 3, 5, 7, 3], [5, 8, 1, 4, 5]]
	if not IS_LOCAL:
		n = read_one()
		a = [read_multiple(list), read_multiple(list)]
	m = [0, 0]
	for i in range(n):
		t0 = max(m[1] + a[0][i], m[0])
		t1 = max(m[0] + a[1][i], m[1])
		m = [t0, t1]
	print(max(m))
if len(sys.argv) > 1 and sys.argv[1] == 'True':
	IS_LOCAL = True
main()


n = int(input())
(*a,) = map(int, input().split())
(*b,) = map(int, input().split())
aa = []
bb = []
ma = int(0)
mb = int(0)
for i in range(n):
	aa.append(mb + a[i])
	bb.append(ma + b[i])
	if aa[i] > ma:
		ma = aa[i]
	if bb[i] > mb:
		mb = bb[i]
print(max(ma, mb))


def main():
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	for i in range(1, n):
		if i == 1:
			arr1[i] += arr2[i - 1]
			arr2[i] += arr1[i - 1]
		else:
			arr1[i] += max(arr2[i - 1], arr2[i - 2])
			arr2[i] += max(arr1[i - 1], arr1[i - 2])
	print(max(arr1[-1], arr2[-1]))
main()


n = int(input())
h1 = [int(i) for i in input().split()]
h2 = [int(j) for j in input().split()]
dp = []
for x in range(n + 1):
	dp.append([0, 0])
dp[0][0] = 0
dp[0][1] = 0
for i in range(1, n + 1):
	dp[i][0] = max(dp[i - 1][1] + h1[i - 1], dp[i - 1][0])
	dp[i][1] = max(dp[i - 1][0] + h2[i - 1], dp[i - 1][1])
print(max(dp[n][0], dp[n][1]))


from sys import setcheckinterval, stdin
setcheckinterval(1000)
iin = lambda : int(stdin.readline())
lin = lambda : list(map(int, stdin.readline().split()))
n = iin()
a = lin()
b = lin()
for i in range(n - 2, -1, -1):
	a[i] = max(a[i] + b[i + 1], a[i + 1])
	b[i] = max(b[i] + a[i + 1], b[i + 1])
print(max(*a, *b))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dp = [[0, 0]]
dp[0][0] = a[0]
dp[0][1] = b[0]
for i in range(1, n):
	t1 = max(dp[-1][0], dp[-1][1] + a[i])
	t2 = max(dp[-1][1], dp[-1][0] + b[i])
	dp.append([t1, t2])
print(max(dp[-1]))


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
dp1 = [0]
dp2 = [0]
for i in range(n):
	dp1.append(max(dp1[-1], dp2[-1] + h1[i]))
	dp2.append(max(dp2[-1], dp1[-2] + h2[i]))
print(max(dp1[-1], dp2[-1]))


n = int(input())
a1 = [int(x) for x in input().split()]
a2 = [int(x) for x in input().split()]
dp = [[0 for i in range(n)] for j in range(2)]
dp[0][n - 1] = a1[n - 1]
dp[1][n - 1] = a2[n - 1]
if n > 1:
	dp[0][n - 2] = a1[n - 2] + a2[n - 1]
	dp[1][n - 2] = a2[n - 2] + a1[n - 1]
for i in range(n - 3, -1, -1):
	dp[0][i] = a1[i] + max(dp[1][i + 1], dp[1][i + 2])
	dp[1][i] = a2[i] + max(dp[0][i + 1], dp[0][i + 2])
print(max(dp[0][0], dp[1][0]))


n = int(input())
above = [int(x) for x in input().split()]
below = [int(x) for x in input().split()]
taken_above = [above[0]]
taken_below = [below[0]]
taken_none = [0]
for i in range(1, n):
	taken_above.append(max(taken_below[i - 1] + above[i], taken_none[i - 1] + above[i]))
	taken_below.append(max(taken_above[i - 1] + below[i], taken_none[i - 1] + below[i]))
	taken_none.append(max(taken_none[i - 1], taken_below[i - 1], taken_above[i - 1]))
print(max(taken_above[n - 1], taken_below[n - 1], taken_none[n - 1]))


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
mat = [[0 for j in range(2)] for i in range(n)]
for i in range(n):
	mat[i][0] = a[i]
	mat[i][1] = b[i]
dp = [[0 for j in range(2)] for i in range(n)]
dp[0][0] = a[0]
dp[0][1] = b[0]
for i in range(1, n):
	dp[i][0] = max(dp[i - 1][0], dp[i - 1][1] + a[i])
	dp[i][1] = max(dp[i - 1][1], dp[i - 1][0] + b[i])
print(max(dp[n - 1][0], dp[n - 1][1]))


n = int(input())
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))
if n > 1:
	s1[1] = s2[0] + s1[1]
	s2[1] = s1[0] + s2[1]
	m = max(s1[0], s1[1], s2[0], s2[1])
	for i in range(2, n):
		s1[i] = max(s2[i - 1] + s1[i], s2[i - 2] + s1[i])
		s2[i] = max(s1[i - 1] + s2[i], s1[i - 2] + s2[i])
		if max(s1[i], s2[i]) > m:
			m = max(s1[i], s2[i])
else:
	m = max(s1[0], s2[0])
print(m)


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
dp = [[0, 0] for _ in range(n + 1)]
for i in range(1, n + 1):
	dp[i][0] = max(dp[i - 1][1] + h1[i - 1], dp[i - 1][0])
	dp[i][1] = max(dp[i - 1][0] + h2[i - 1], dp[i - 1][1])
print(max(dp[n][0], dp[n][1]))


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
dp1 = [0] * N
dp2 = [0] * N
dp1[0] = A[0]
dp2[0] = B[0]
if N > 1:
	dp1[1] = dp2[0] + A[1]
	dp2[1] = dp1[0] + B[1]
	for i in range(2, N):
		dp1[i] = max(A[i] + dp2[i - 1], A[i] + dp2[i - 2])
		dp2[i] = max(B[i] + dp1[i - 1], B[i] + dp1[i - 2])
print(max(dp1[N - 1], dp2[N - 1]))


n = int(input())
l1 = [int(i) for i in input().split(' ')]
l2 = [int(i) for i in input().split(' ')]
l = [l1, l2]

def find_max_dp():
	dp = [[0] * n, [0] * n]
	dp[0][0] = l[0][0]
	dp[1][0] = l[1][0]
	if n > 1:
		dp[0][1] = l[0][1] + dp[1][0]
		dp[1][1] = l[1][1] + dp[0][0]
	for i in range(1, n):
		dp[1][i] = max(dp[0][i - 1], dp[0][i - 2]) + l[1][i]
		dp[0][i] = max(dp[1][i - 1], dp[1][i - 2]) + l[0][i]
	return max(dp[1][n - 1], dp[0][n - 1])
print(find_max_dp())


n = int(input())
l = [[0], [0]]
topmax = 0
botmax = 0
l[0].extend(list(map(int, input().split())))
l[1].extend(list(map(int, input().split())))
for i in range(1, n + 1):
	l[0][i] = l[0][i] + botmax
	l[1][i] = l[1][i] + topmax
	topmax = max(topmax, l[0][i])
	botmax = max(botmax, l[1][i])
print(max(topmax, botmax))


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
if n == 1:
	print(max(a[0], b[0]))
elif n == 2:
	print(max(a[0] + b[1], b[0] + a[1]))
else:
	dp = [[a[0], b[0]], [b[0] + a[1], a[0] + b[1]]]
	for i in range(2, n):
		dp.append([max(dp[-1][1], max(dp[-2])) + a[i], max(dp[-1][0], max(dp[-2])) + b[i]])
	print(max(dp[-1]))


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
n = INI()
A = INL()
B = INL()
if n == 1:
	OPS(max(A[0], B[0]))
elif n == 2:
	OPS(max(A[0] + B[1], B[0] + A[1]))
else:
	X = [A[0], B[0] + A[1]]
	Y = [B[0], A[0] + B[1]]
	for _ in range(2, n):
		X.append(A[_] + max(Y[_ - 1], Y[_ - 2]))
		Y.append(B[_] + max(X[_ - 1], X[_ - 2]))
	OPS(max(X[-1], Y[-1]))


from sys import stdin, stdout
import cProfile, math
from collections import Counter, defaultdict, deque
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
fac_warmup = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys

class merge_find:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n
		self.lista = [[_] for _ in range(n)]

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]
		self.lista[a] += self.lista[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def all_factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def fibonacci_modP(n, MOD):
	if n < 2:
		return 1
	return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * cached_fn(InverseEuler, i, p) % p
	return res

def binary(n, digits=20):
	b = bin(n)[2:]
	b = '0' * (digits - len(b)) + b
	return b

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def generate_primes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	return prime
factorial_modP = []

def warm_up_fac(MOD):
	nonlocal factorial_modP, fac_warmup
	if fac_warmup:
		return
	factorial_modP = [1 for _ in range(fac_warmup_size + 1)]
	for i in range(2, fac_warmup_size):
		factorial_modP[i] = factorial_modP[i - 1] * i % MOD
	fac_warmup = True

def InverseEuler(n, MOD):
	return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
	nonlocal fac_warmup, factorial_modP
	if not fac_warmup:
		warm_up_fac(MOD)
		fac_warmup = True
	return factorial_modP[n] * (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD) % MOD) % MOD

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def display_2D_list(li):
	for i in li:
		print(i)

def prefix_sum(li):
	sm = 0
	res = []
	for i in li:
		sm += i
		res.append(sm)
	return res

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
import heapq, itertools
pq = []
entry_finder = {}
REMOVED = '<removed-task>'

def add_task(task, priority=0):
	if task in entry_finder:
		remove_task(task)
	count = next(counter)
	entry = [priority, count, task]
	entry_finder[task] = entry
	heapq.heappush(pq, entry)

def remove_task(task):
	entry = entry_finder.pop(task)
	entry[-1] = REMOVED

def pop_task():
	while pq:
		(priority, count, task) = heapq.heappop(pq)
		if task is not REMOVED:
			del entry_finder[task]
			return task
	raise KeyError('pop from an empty priority queue')
memory = dict()

def clear_cache():
	nonlocal memory
	memory = dict()

def cached_fn(fn, *args):
	nonlocal memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def ncr(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def binary_serach(i, li):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = False
testingMode = False
fac_warmup_size = 10 ** 5 + 100
optimiseForReccursion = False
from math import factorial

def main():
	n = get_int()
	a = get_list()
	b = get_list()
	u = [0, 0]
	l = [0, 0]
	for i in range(n):
		u.append(max(l[-1], l[-2], u[-2]) + b[i])
		l.append(max(u[-2], u[-3], l[-2]) + a[i])
	print(max(u[-1], l[-1]))
if TestCases:
	for i in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


import collections
import random
import heapq
import bisect
import math
import time

class Solution2:

	def solve(self, s):
		pass

class Solution:

	def solve(self, row1, row2):
		dp = [0, 0]
		for i in range(len(row1)):
			new_dp = [0, 0]
			new_dp[0] = max(dp[0], dp[1] + row2[i])
			new_dp[1] = max(dp[1], dp[0] + row1[i])
			dp = new_dp
		return max(dp)
sol = Solution()
sol2 = Solution2()
for test_case in range(1):
	N = input()
	s = [int(c) for c in input().split()]
	s2 = [int(c) for c in input().split()]
	out = sol.solve(s, s2)
	print(str(out))


from sys import stdin, stdout, setrecursionlimit
import threading

class Tail_Recursion_Optimization:

	def __init__(self, RECURSION_LIMIT, STACK_SIZE):
		setrecursionlimit(RECURSION_LIMIT)
		threading.stack_size(STACK_SIZE)
		return None

class SOLVE:
	n = None
	a = []

	def DP(self, which, pos, dp):
		if pos == self.n:
			return 0
		if pos != which != None and dp[which][pos] != None:
			return dp[which][pos]
		if which == pos == None:
			total1 = total2 = 0
			total1 += self.a[0][0] + self.DP(1, 1, dp)
			total2 += self.DP(0, 1, dp)
			dp[0][0] = max(total1, total2)
			total1 = total2 = 0
			total1 += self.a[1][0] + self.DP(0, 1, dp)
			total2 += self.DP(1, 1, dp)
			dp[1][0] = max(total1, total2)
			return max(dp[0][0], dp[1][0])
		else:
			total1 = total2 = 0
			total1 = total2 = 0
			total1 += self.a[which][pos] + self.DP(which ^ 1, pos + 1, dp)
			total2 += self.DP(which, pos + 1, dp)
			dp[which][pos] = max(total1, total2)
			return dp[which][pos]

	def solve(self):
		R = stdin.readline
		W = stdout.write
		self.n = int(R())
		tmp1 = [int(x) for x in R().split()]
		tmp2 = [int(x) for x in R().split()]
		self.a.append(tmp1)
		self.a.append(tmp2)
		dp = [[None for i in range(self.n)] for j in range(2)]
		W('%d\n' % self.DP(None, None, dp))
		return 0

def main():
	s = SOLVE()
	s.solve()
Tail_Recursion_Optimization(10 ** 7, 100 * 1024 ** 2)
threading.Thread(target=main).start()


n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
t = [[0 for i in range(3)] for j in range(n + 1)]
for i in range(1, n + 1):
	t[i][0] = max(t[i - 1])
	t[i][1] = max(t[i - 1][0], t[i - 1][2]) + x[i - 1]
	t[i][2] = max(t[i - 1][0], t[i - 1][1]) + y[i - 1]
print(max(t[n]))


from collections import defaultdict
n = int(input())
x = []
x.append([int(i) for i in input().split()])
x.append([int(i) for i in input().split()])
dp = [[0 for _ in range(n)] for _ in range(2)]
dp[0][0] = x[0][0]
dp[1][0] = x[1][0]
for j in range(1, n):
	for i in range(2):
		dp[i][j] = max(dp[1 - i][j - 1] + x[i][j], dp[i][j - 1])
print(max(dp[0][-1], dp[1][-1]))


n = int(input())
h0 = list(map(int, input().split()))
h1 = list(map(int, input().split()))
dp = [[0 for i in range(n)], [0 for j in range(n)]]
dp[0][0] = h0[0]
dp[1][0] = h1[0]
for i in range(1, n):
	dp[0][i] = max(dp[0][i - 1], dp[1][i - 1] + h0[i])
	dp[1][i] = max(dp[1][i - 1], dp[0][i - 1] + h1[i])
print(max(dp[1][n - 1], dp[0][n - 1]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a1 = [0] * n
b1 = [0] * n
a1[0] = a[0]
b1[0] = b[0]
if n > 1:
	a1[1] = b[0] + a[1]
	b1[1] = a[0] + b[1]
for i in range(2, n):
	a1[i] = max(b1[i - 1] + a[i], b1[i - 2] + a[i], a1[i - 1])
	b1[i] = max(a1[i - 1] + b[i], a1[i - 2] + b[i], b1[i - 1])
print(max(a1[n - 1], b1[n - 1]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = y = 0
for i in range(n):
	(x, y) = (max(x, y + a[i]), max(y, x + b[i]))
print(max(x, y))


n = int(input())
row_one = [int(height) for height in input().split(' ')]
row_two = [int(height) for height in input().split(' ')]
if n == 1:
	print(max(row_one[0], row_two[0]))
elif n == 2:
	print(max(row_one[0] + row_two[1], row_one[1] + row_two[0]))
else:
	row_one[1] = row_one[1] + row_two[0]
	row_two[1] = row_two[1] + row_one[0]
	for col_idx in range(2, n):
		row_one[col_idx] = row_one[col_idx] + max(row_two[col_idx - 1], row_two[col_idx - 2])
		row_two[col_idx] = row_two[col_idx] + max(row_one[col_idx - 1], row_one[col_idx - 2])
	print(max(row_one[n - 1], row_two[n - 1]))


def solve(n, ar, ar2):
	dp = [[-1] * 2 for i in range(n)]
	dp[0][0] = ar[0]
	dp[0][1] = ar2[0]
	for i in range(1, n):
		for j in range(2):
			if j == 0:
				dp[i][j] = max(dp[i][j], dp[i - 1][1] + ar[i])
				if i > 1:
					dp[i][j] = max(dp[i][j], dp[i - 2][1] + ar[i])
			if j == 1:
				dp[i][j] = max(dp[i][j], dp[i - 1][0] + ar2[i])
				if i > 1:
					dp[i][j] = max(dp[i][j], dp[i - 2][0] + ar2[i])
	print(max(dp[n - 1][0], dp[n - 1][1]))
n = int(input())
ar = list(map(int, input().split()))
ar2 = list(map(int, input().split()))
solve(n, ar, ar2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(1, n):
	a[i] = max(a[i - 1], a[i] + b[i - 1])
	b[i] = max(b[i - 1], b[i] + a[i - 1])
print(max(b[n - 1], a[n - 1]))


import sys
import math
n = int(sys.stdin.readline())
a = [0] + list(map(int, sys.stdin.readline().split()))
b = [0] + list(map(int, sys.stdin.readline().split()))
if n == 1:
	exit(print(max(a[1], b[1])))
dp = [[0] * 2 for i in range(n + 1)]
dp[1][0] = a[1]
dp[1][1] = b[1]
dp[2][0] = a[2] + b[1]
dp[2][1] = b[2] + a[1]
m1 = a[0]
m2 = b[0]
for i in range(2, n + 1):
	dp[i][0] = max(dp[i - 1][1], dp[i - 2][1]) + a[i]
	dp[i][1] = max(dp[i - 1][0], dp[i - 2][0]) + b[i]
print(max(dp[n - 1][0], dp[n - 1][1], dp[n][0], dp[n][1]))


def f(l1, l2, index=0, currsum=0, prev=0, memo=dict()):
	key = (index, currsum, prev)
	if key in memo:
		return memo[key]
	if index == len(l1):
		return currsum
	if prev == 0:
		to_return = max(f(l1, l2, index + 1, currsum + l1[index], 1, memo), f(l1, l2, index + 1, currsum + l2[index], 2, memo), f(l1, l2, index + 1, currsum, prev, memo))
	elif prev == 2:
		to_return = max(f(l1, l2, index + 1, currsum + l1[index], 1, memo), f(l1, l2, index + 1, currsum, prev, memo))
	elif prev == 1:
		to_return = max(f(l1, l2, index + 1, currsum + l2[index], 2, memo), f(l1, l2, index + 1, currsum, prev, memo))
	memo[key] = to_return
	return to_return

def iterative(l1, l2):
	n = len(l1)
	dp1 = [0] * n
	dp2 = [0] * n
	dp1[0] = l1[0]
	dp2[0] = l2[0]
	for i in range(1, n):
		dp1[i] = max(dp2[i - 1] + l1[i], dp1[i - 1])
		dp2[i] = max(dp1[i - 1] + l2[i], dp2[i - 1])
	return max(dp1[n - 1], dp2[n - 1])
input()
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
print(iterative(l1, l2))


import math
n = int(input())
a = input().split()
b = input().split()
c = [[0 for i in range(n)] for j in range(2)]
for i in range(n):
	c[0][i] = int(a[i])
	c[1][i] = int(b[i])
dp = [[0 for i in range(n)] for j in range(2)]
dp[0][0] = c[0][0]
dp[1][0] = c[1][0]
for i in range(1, n):
	for j in range(2):
		dp[j][i] = max(dp[j][i - 1], dp[1 - j][i - 1] + c[j][i])
print(max(dp[0][n - 1], dp[1][n - 1]))


def c():
	n = int(input())
	h1 = [int(x) for x in input().split()]
	h2 = [int(x) for x in input().split()]
	if n == 1:
		print(max(h1[0], h2[0]))
		return
	dp1 = [0] * n
	dp2 = [0] * n
	(dp1[0], dp2[0]) = (h1[0], h2[0])
	dp1[1] = h2[0] + h1[1]
	dp2[1] = h2[1] + h1[0]
	for i in range(2, n):
		dp1[i] = h1[i] + max(dp2[i - 1], dp2[i - 2])
		dp2[i] = h2[i] + max(dp1[i - 1], dp1[i - 2])
	print(max(dp1[-1], dp2[-1]))
	return 0
c()


from sys import stdin, stdout
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
r1 = r2 = 0
for i in range(n):
	(r1, r2) = (max(r1, r2 + a[i]), max(r2, r1 + b[i]))
stdout.write(str(max(r1, r2)) + '\n')


input()
(c, d) = (0, 0)
for (i, j) in zip(map(int, input().split()), map(int, input().split())):
	(c, d) = (max(c, d + i), max(d, c + j))
print(max(c, d))


import sys
input = sys.stdin.readline
n = int(input())
h = [list(map(int, input().split())) for _ in range(2)]
if n == 1:
	print(max(h[0][0], h[1][0]))
	exit()
elif n == 2:
	print(max(h[1][0] + h[0][1], h[0][0] + h[1][1]))
	exit()
dp = [[0] * 2 for _ in range(n + 1)]
(dp[1][0], dp[1][1]) = (h[0][0], h[1][0])
(dp[2][0], dp[2][1]) = (h[1][0] + h[0][1], h[0][0] + h[1][1])
for i in range(2, n):
	dp[i + 1][0] = max(dp[i][1], dp[i - 1][1]) + h[0][i]
	dp[i + 1][1] = max(dp[i][0], dp[i - 1][0]) + h[1][i]
print(max(dp[n]))


n = int(input())
a = [*map(int, input().split())]
b = [*map(int, input().split())]
cache1 = [a[0]]
cache2 = [b[0]]
for i in range(n - 1):
	cache1.append(max(cache1[i], cache2[i] + a[i + 1]))
	cache2.append(max(cache2[i], cache1[i] + b[i + 1]))
print(max(cache1[-1], cache2[-1]))


n = int(input())
h = [None] * 2
h[0] = list(map(int, input().split()))
h[1] = list(map(int, input().split()))
top_max = h[0][0]
bot_max = h[1][0]
for col in range(1, n):
	new_top_max = max(top_max, bot_max + h[0][col])
	new_bot_max = max(bot_max, top_max + h[1][col])
	top_max = new_top_max
	bot_max = new_bot_max
total_max = max(top_max, bot_max)
print(total_max)


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
if n == 1:
	print(max(h1[0], h2[0]))
	exit(0)
x1 = [0] * n
x2 = [0] * n
x1[0] = h1[0]
x2[0] = h2[0]
x1[1] = x2[0] + h1[1]
x2[1] = x1[0] + h2[1]
for i in range(2, n):
	if i % 2:
		x1[i] = h1[i] + max(x2[i - 1], x2[i - 2])
		x2[i] = h2[i] + max(x1[i - 1], x1[i - 2])
	else:
		x1[i] = h1[i] + max(x2[i - 1], x2[i - 2])
		x2[i] = h2[i] + max(x1[i - 1], x1[i - 2])
print(max(x1[-1], x2[-1]))


n = int(input())
r1 = [int(i) for i in input().split(' ')]
r2 = [int(i) for i in input().split(' ')]
stat = [-1] * 240000
rm1 = r1[-1]
rm2 = r2[-1]
for i in range(n - 2, -1, -1):
	nrm1 = max(rm1, rm2 + r1[i])
	nrm2 = max(rm2, rm1 + r2[i])
	rm1 = nrm1
	rm2 = nrm2
print(max(rm1, rm2))


a = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
dp = [0] * (a + 10)
dp[1] = b[0]
dp1 = [0] * (a + 10)
dp1[1] = c[0]
max0 = dp[1]
max1 = dp1[1]
for i in range(2, a + 1):
	dp[i] = max1 + b[i - 1]
	dp1[i] = max0 + c[i - 1]
	max0 = max(max0, dp[i])
	max1 = max(max1, dp1[i])
print(max(dp[a], dp1[a]))


import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
	return int(input())

def getList():
	return list(map(int, input().split()))
import math
n = getN()
anums = getList()
bnums = getList()
if n == 1:
	print(max(anums[0], bnums[0]))
	sys.exit()
dp1 = [0 for i in range(n)]
dp2 = [0 for i in range(n)]
dp1[0] = anums[0]
dp1[1] = anums[1] + bnums[0]
dp2[0] = bnums[0]
dp2[1] = bnums[1] + anums[0]
i = 0
for (a, b) in zip(anums[2:], bnums[2:]):
	dp1[i + 2] = max(dp1[i], dp2[i + 1], dp2[i]) + a
	dp2[i + 2] = max(dp2[i], dp1[i + 1], dp1[i]) + b
	i += 1
print(max(dp1[-1], dp1[-2], dp2[-1], dp2[-2]))


n = int(input())
r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
dp = [[0, 0, 0] for _ in range(n)]
dp[0] = [r1[0], r2[0], 0]
for i in range(1, n):
	last = dp[i - 1]
	dp[i][0] = max(last[1], last[2]) + r1[i]
	dp[i][1] = max(last[0], last[2]) + r2[i]
	dp[i][2] = max(last[0], last[1])
print(max(dp[n - 1]))


def solve4(line1, line2):
	memo = {}
	memo[True, len(line1) - 1] = line1[len(line1) - 1]
	memo[False, len(line1) - 1] = line2[len(line1) - 1]
	for i in range(len(line1) - 2, -1, -1):
		optionPeek = memo[False, i + 1] + line1[i]
		optionSkip = memo[True, i + 1]
		memo[True, i] = max(optionPeek, optionSkip)
		optionPeek = memo[True, i + 1] + line2[i]
		optionSkip = memo[False, i + 1]
		memo[False, i] = max(optionPeek, optionSkip)
	return max(memo[True, 0], memo[False, 0])

def solve3(line1, line2, direction, index, memo):
	peekValue = line1[index]
	if not direction:
		peekValue = line2[index]
	if index + 1 == len(line1):
		memo[direction, index] = peekValue
		return memo[direction, index]
	if (not direction, index + 1) not in memo:
		memo[not direction, index + 1] = solve3(line1, line2, not direction, index + 1, memo)
	optionPeek = memo[not direction, index + 1] + peekValue
	if (direction, index + 1) not in memo:
		memo[direction, index + 1] = solve3(line1, line2, direction, index + 1, memo)
	optionSkip = memo[direction, index + 1]
	return max(optionPeek, optionSkip)

def solve2(line1, line2, index):
	if index + 1 == len(line1):
		return line1[index]
	optionPeek = solve2(line2, line1, index + 1) + line1[index]
	optionSkip = solve2(line1, line2, index + 1)
	return max(optionPeek, optionSkip)

def main_solve(line1, line2):
	if len(line1) == 1:
		return max(line1[0], line2[0])
	return solve4(line1, line2)

def solve(line1, line2):
	if len(line1) == 1:
		return line1[0]
	optionPeek = solve(line2[1:], line1[1:]) + line1[0]
	optionSkip = solve(line1[1:], line2[1:])
	return max(optionPeek, optionSkip)
n = int(input())
lst1 = [int(x) for x in input().split()]
lst2 = [int(x) for x in input().split()]
solution = main_solve(lst1, lst2)
print(solution)


x = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
lol = []
for i in range(2):
	lol.append([0] * x)
lol[0][0] = a[0]
lol[1][0] = b[0]
if x > 1:
	lol[0][1] = lol[1][0] + a[1]
	lol[1][1] = lol[0][0] + b[1]
	for i in range(2, x):
		lol[0][i] = max(lol[1][i - 1] + a[i], a[i] + lol[1][i - 2])
		lol[1][i] = max(b[i] + lol[0][i - 1], b[i] + lol[0][i - 2])
print(max(lol[0][x - 1], lol[1][x - 1]))


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		a = list(In())
		b = list(In())
		(max_a, max_b) = (0, 0)
		ans = 0
		for x in range(n):
			(max_a, max_b) = (max(a[x] + max_b, max_a), max(b[x] + max_a, max_b))
			ans = max(max_b, max_a, ans)
		print(ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


n = int(input())
l = [[*map(int, input().split())], [*map(int, input().split())]]
dp = [0, 0]
for i in range(n):
	new_dp = dp[:]
	new_dp[0] = max(new_dp[0], dp[1] + l[0][i])
	new_dp[1] = max(new_dp[1], dp[0] + l[1][i])
	dp = new_dp
print(max(dp))


n = int(input())
s1 = [int(i) for i in input().split()]
s2 = [int(i) for i in input().split()]
c1 = 0
c2 = 0
for i in range(n):
	temp1 = max(c1, c2 + s1[i])
	temp2 = max(c2, c1 + s2[i])
	c1 = temp1
	c2 = temp2
print(max(c1, c2))


n = int(input())
k = []
for i in range(2):
	vs = list(map(int, input().split()))
	vs = [0] + vs
	k.append(vs)
f = [0] * (n + 1)
s = [0] * (n + 1)
f[1] = k[0][1]
s[1] = k[1][1]
for i in range(2, n + 1):
	f[i] = max(s[i - 1], s[i - 2]) + k[0][i]
	s[i] = max(f[i - 1], f[i - 2]) + k[1][i]
ans = 0
for i in f:
	ans = max(ans, i)
for i in s:
	ans = max(ans, i)
print(ans)


n = int(input())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
c = [0 for i in range(n)]
d = [0 for i in range(n)]
c[n - 1] = a[n - 1]
d[n - 1] = b[n - 1]
for i in range(n - 2, -1, -1):
	c[i] = max(c[i + 1], a[i] + d[i + 1])
	d[i] = max(d[i + 1], b[i] + c[i + 1])
print(max(c[0], d[0]))


def CF1195C():
	N = int(input())
	r1 = tuple(map(int, input().split()))
	r2 = tuple(map(int, input().split()))
	r1sum = r1[-1]
	r2sum = r2[-1]
	for i in range(N - 2, -1, -1):
		(r1sum, r2sum) = (max(r1[i] + r2sum, r1sum), max(r2[i] + r1sum, r2sum))
	return max(r1sum, r2sum)
res = CF1195C()
print(res)


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
score = [[0 for x in range(n)] for _ in range(2)]
if n == 1:
	print(max(a[0], b[0]))
	return
elif n == 2:
	print(max(a[0] + b[1], b[0] + a[1]))
	return
score[0][0] = a[0]
score[1][0] = b[0]
score[1][1] = a[0] + b[1]
score[0][1] = b[0] + a[1]
for x in range(2, n):
	score[0][x] = max(score[1][x - 1], score[1][x - 2]) + a[x]
	score[1][x] = max(score[0][x - 1], score[0][x - 2]) + b[x]
print(max(score[0][-1], score[1][-1]))


n = int(input())
first_line = list(map(int, input().split()))
second_line = list(map(int, input().split()))
s1 = 0
s2 = 0
for _ in range(n):
	t1 = max(s1, s2 + first_line[_])
	t2 = max(s1 + second_line[_], s2)
	s1 = t1
	s2 = t2
ans = max(s1, s2)
print(ans)


n = int(input())
l1 = [int(s) for s in input().split()]
l2 = [int(s) for s in input().split()]
if n == 1:
	print(max(l1[0], l2[0]))
elif n == 2:
	print(max(l1[0] + l2[1], l2[0] + l1[0]))
else:
	re1 = [0] * n
	re2 = [0] * n
	re1[0] = l1[0]
	re2[0] = l2[0]
	re1[1] = re2[0] + l1[1]
	re2[1] = re1[0] + l2[1]
	for i in range(2, n):
		re1[i] = max(re2[i - 1], re2[i - 2]) + l1[i]
		re2[i] = max(re1[i - 1], re1[i - 2]) + l2[i]
	print(max(re1[n - 1], re2[n - 1]))


n = int(input().strip())
num1 = [int(i) for i in input().strip().split()]
num2 = [int(i) for i in input().strip().split()]
dp1 = [0 for i in range(n)]
dp2 = [0 for i in range(n)]
if n == 1:
	print(max(num1[0], num2[0]))
else:
	dp1[0] = num1[0]
	dp2[0] = num2[0]
	dp1[1] = dp2[0] + num1[1]
	dp2[1] = dp1[0] + num2[1]
	for i in range(2, n):
		dp1[i] = max(dp2[i - 1] + num1[i], dp2[i - 2] + num1[i])
		dp2[i] = max(dp1[i - 1] + num2[i], dp1[i - 2] + num2[i])
	print(max(dp1[-1], dp2[-1]))


import io, sys
input = lambda f=io.StringIO(sys.stdin.buffer.read().decode()).readline: f().rstrip()
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
n = ii()
a = li()
b = li()
dp = [[0, 0] for _ in range(n + 1)]
for i in range(n):
	dp[i][0] = max(a[i] + dp[i - 1][1], dp[i - 1][0])
	dp[i][1] = max(b[i] + dp[i - 1][0], dp[i - 1][1])
ans = max(dp[n - 1])
print(ans)


import sys
sys.setrecursionlimit(2 * 10 ** 5 + 1)
n = int(input())
a = [[int(x) for x in input().split()] for t in range(2)]
ans = [0, 0]
for i in range(n):
	(ans[0], ans[1]) = (max(ans[0], ans[1] + a[0][i]), max(ans[1], ans[0] + a[1][i]))
print(max(ans))


n = int(input())
ar = list(map(int, input().split()))
br = list(map(int, input().split()))
flag = True
dp = [0] * n
dp1 = [0] * n
dp[0] = ar[0]
dp1[0] = br[0]
for i in range(1, n):
	if i < 2:
		dp[i] = max(dp1[i - 1] + ar[i], dp[i], ar[i])
		dp1[i] = max(dp[i - 1] + br[i], dp1[i], br[i])
	else:
		dp[i] = max(dp1[i - 1] + ar[i], dp1[i - 2] + ar[i])
		dp1[i] = max(dp[i - 1] + br[i], dp[i - 2] + br[i])
print(max(dp1[-1], dp[-1]))


n = int(input())
a1 = list(map(int, input().split(' ')))
a2 = list(map(int, input().split(' ')))
dp1 = [[0, 0] for _ in range(n)]
dp2 = [[0, 0] for _ in range(n)]
dp1[0][0] = a1[0]
dp2[0][0] = a2[0]
for i in range(1, n):
	dp1[i][0] = max([dp1[i - 1][1], dp2[i - 1][0], dp2[i - 1][1]]) + a1[i]
	dp1[i][1] = max([dp1[i - 1][0], dp1[i - 1][1], dp2[i - 1][0], dp2[i - 1][1]])
	dp2[i][0] = max([dp2[i - 1][1], dp1[i - 1][0], dp1[i - 1][1]]) + a2[i]
	dp2[i][1] = max([dp2[i - 1][1], dp2[i - 1][0], dp1[i - 1][0], dp1[i - 1][1]])
e = n - 1
print(max([dp1[e][0], dp1[e][1], dp2[e][0], dp2[e][1]]))


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
r1 = r2 = 0
for i in range(n):
	(r1, r2) = (max(r1, r2 + h1[i]), max(r2, r1 + h2[i]))
print(max(r1, r2))


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
a = h1[0]
b = h2[0]
c = 0
for i in range(1, n):
	(p, q, r) = (a, b, c)
	a = max(q, r) + h1[i]
	b = max(p, r) + h2[i]
	c = max(p, q, r)
print(max(a, b, c))


n = int(input())
team1 = list(map(int, input().split()))
team2 = list(map(int, input().split()))
team1 = [0, 0] + team1
team2 = [0, 0] + team2
ans1 = [0, 0]
ans2 = [0, 0]
for i in range(2, n + 2):
	ans1.append(max(ans1[i - 2] + team1[i], ans2[i - 2] + team1[i], ans2[i - 1] + team1[i]))
	ans2.append(max(ans2[i - 2] + team2[i], ans1[i - 1] + team2[i], ans1[i - 2] + team2[i]))
print(max(ans1[-1], ans2[-1]))


import sys
inf = float('inf')
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr1 = get_array()
Arr2 = get_array()
dp = [[0 for i in range(n)] for i in range(2)]
dp[0][0] = Arr1[0]
dp[1][0] = Arr2[0]
for i in range(1, n):
	dp[0][i] = max(dp[0][i - 1], Arr1[i] + dp[1][i - 1])
	dp[1][i] = max(dp[1][i - 1], Arr2[i] + dp[0][i - 1])
print(max(dp[0][n - 1], dp[1][n - 1]))


from collections import defaultdict as dd, deque as dq
import math, string
import sys

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	dp = [[0 for j in range(2)] for i in range(N + 1)]
	A = []
	A.append([0] + getInts())
	A.append([0] + getInts())
	A = list(zip(*A))
	for i in range(1, N + 1):
		for j in range(2):
			dp[i][j] = max(dp[i - 1][j], dp[i - 1][1 - j] + A[i][j])
	return max(dp[N][0], dp[N][1])
print(solve())


n = int(input())
h0 = [int(x) for x in input().split()]
h1 = [int(x) for x in input().split()]
dp = [[0] * n for _ in range(3)]
dp[0][0] = h0[0]
dp[1][0] = h1[0]
for i in range(1, n):
	dp[0][i] = max(dp[1][i - 1] + h0[i], dp[2][i - 1] + h0[i], h0[i])
	dp[1][i] = max(dp[0][i - 1] + h1[i], dp[2][i - 1] + h1[i], h1[i])
	dp[2][i] = max(dp[0][i - 1], dp[1][i - 1])
print(max(dp[1][n - 1], dp[0][n - 1], dp[2][n - 1]))


n = int(input())
arr1 = [int(i) for i in input().split()]
arr2 = [int(i) for i in input().split()]
maxleft = arr1[-1]
maxright = arr2[-1]
extra = 0
dp = [(0, 0) for i in range(n)]
dp[n - 1] = (maxleft, maxright)
ans = max(maxleft, maxright)
for i in range(n - 2, -1, -1):
	if i + 2 < n:
		maxleft = max(maxleft, arr1[i] + dp[i + 1][1], arr1[i] + dp[i + 2][1])
		maxright = max(maxright, arr2[i] + dp[i + 1][0], arr2[i] + dp[i + 2][0])
		dp[i] = (maxleft, maxright)
	else:
		maxleft = max(maxleft, arr1[i] + dp[i + 1][1])
		maxright = max(maxright, arr2[i] + dp[i + 1][0])
		dp[i] = (maxleft, maxright)
	ans = max(ans, dp[i][0], dp[i][1])
print(ans)


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
m1 = l1[0]
m2 = l2[0]
ans = max(m1, m2)
i = 1
while i < n:
	l1[i] = max(l1[i], l1[i] + m2)
	l2[i] = max(l2[i], l2[i] + m1)
	m1 = max(m1, l1[i])
	m2 = max(m2, l2[i])
	ans = max(ans, l1[i], l2[i])
	i = i + 1
print(ans)


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
dp1 = [0] * n
dp2 = [0] * n
for i in range(n):
	if i == 0:
		dp1[i] = h1[0]
		dp2[i] = h2[0]
	else:
		dp1[i] = max(dp1[i - 1], dp2[i - 1] + h1[i])
		dp2[i] = max(dp2[i - 1], dp1[i - 1] + h2[i])
print(max(dp1[n - 1], dp2[n - 1]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if n == 1:
	print(max(a[0], b[0]))
elif n == 2:
	print(max(a[0] + b[1], b[0] + a[1]))
else:
	dp1 = [0] * (n + 1)
	dp2 = [0] * (n + 1)
	dp0 = [0] * (n + 1)
	dp1[1] = a[0]
	dp2[1] = b[0]
	dp0[1] = 0
	dp1[2] = dp2[1] + a[1]
	dp2[2] = dp1[1] + b[1]
	dp0[2] = max(a[0], b[0])
	for i in range(3, n + 1):
		(m, n) = (a[i - 1], b[i - 1])
		dp1[i] = max(dp2[i - 1], dp0[i - 1]) + m
		dp2[i] = max(dp1[i - 1], dp0[i - 1]) + n
		dp0[i] = max(dp1[i - 1], dp2[i - 1])
	print(max(dp1[-1], dp2[-1], dp0[-1]))


n = int(input())
p = [[0] * (n + 1)] + [[0] + list(map(int, input().split())) for _ in range(2)]
t = [[0] * (n + 1) for _ in range(3)]
(t[1][1], t[2][1]) = (p[1][1], p[2][1])
for i in range(2, n + 1):
	t[0][i] = max(t[1][i - 1], t[2][i - 1])
	t[1][i] = p[1][i] + max(t[0][i - 1], t[2][i - 1])
	t[2][i] = p[2][i] + max(t[0][i - 1], t[1][i - 1])
print(max(t[0][n], t[1][n], t[2][n]))


n = int(input())
a = [int(j) for j in input().split()]
b = [int(j) for j in input().split()]
c = [a, b]
res = [[0 for j in range(n + 1)], [0 for i in range(n + 1)]]
for i in range(n):
	for j in [0, 1]:
		if i < n:
			res[not j][i + 1] = max(res[not j][i + 1], res[j][i] + c[not j][i])
		if i < n - 1:
			res[not j][i + 2] = max(res[not j][i + 2], res[j][i] + c[not j][i + 1])
print(max(res[0][-1], res[1][-1]))


n = int(input())
s = [[*map(int, input().split())], [*map(int, input().split())]]
dp = [[0] * n, [0] * n]
dp[0][0] = s[0][0]
dp[1][0] = s[1][0]
if n == 1:
	exit(print(max(dp[0][0], dp[1][0])))
dp[0][1] = s[0][1] + s[1][0]
dp[1][1] = s[1][1] + s[0][0]
for i in range(2, n):
	for j in range(2):
		dp[j][i] = max(dp[1 - j][i - 2], dp[1 - j][i - 1]) + s[j][i]
print(max(sum(dp, [])))


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(sys.stdin.readline())
	if number_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
mod = 100000007
n = vary(1)
n1 = array_int()
n2 = array_int()
dp = [[0 for i in range(3)] for j in range(n + 2)]
ans = 0
for i in range(1, n + 1):
	dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + n1[i - 1]
	dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + n2[i - 1]
	dp[i][2] = max(dp[i - 1][1], dp[i - 1][0])
print(max(dp[n][0], dp[n][1], dp[n][2]))


num = int(input())
array = [int(i) for i in input().split()]
bow = [int(i) for i in input().split()]
ping = [array[0]] + [0] * (num - 1)
alpha = [bow[0]] + [0] * (num - 1)
for i in range(1, num):
	ping[i] = max(alpha[i - 1] + array[i], ping[i - 1])
	alpha[i] = max(ping[i - 1] + bow[i], alpha[i - 1])
print(max(ping[num - 1], alpha[num - 1]))


n = int(input())
h1 = [int(i) for i in input().split()]
h2 = [int(i) for i in input().split()]
for i in range(1, n):
	if i == 1:
		h1[i] += h2[i - 1]
		h2[i] += h1[i - 1]
	else:
		h1[i] += max(h2[i - 1], h1[i - 2], h2[i - 2])
		h2[i] += max(h1[i - 1], h2[i - 2], h1[i - 2])
print(max(h1[-1], h2[-1]))


n = int(input())
h1 = [int(i) for i in input().split()]
h2 = [int(i) for i in input().split()]
for i in range(n):
	mx2 = -1
	if i > 1:
		h1m = max(h2[i - 1], h2[i - 2])
		h1[i] += h1m
		h2m = max(h1[i - 1], h1[i - 2])
		h2[i] += h2m
	elif i == 1:
		h1[i] += h2[i - 1]
		h2[i] += h1[i - 1]
print(max(h1[n - 1], h2[n - 1]))


import sys
n = int(input())
h1 = [int(x) for x in input().split()]
h2 = [int(x) for x in input().split()]
dp = [[0] * (n + 1) for _ in range(2)]
for i in range(1, n + 1):
	dp[0][i] = max(dp[0][i - 1], dp[1][i - 1] + h1[i - 1])
	dp[1][i] = max(dp[1][i - 1], dp[0][i - 1] + h2[i - 1])
print(max(dp[0][n], dp[1][n]))


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
l1 = il()
l2 = il()
sm1 = 0
sm2 = 0
for i in range(n):
	(sm1, sm2) = (max(l1[i] + sm2, sm1), max(l2[i] + sm1, sm2))
print(max(sm1, sm2))


import sys
import math
input = sys.stdin.readline
n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
jugad = [[0 for i in range(3)] for j in range(n)]
jugad[0][0] = arr[0]
jugad[0][1] = brr[0]
for i in range(1, n):
	jugad[i][0] = max(jugad[i - 1][1], jugad[i - 1][2]) + arr[i]
	jugad[i][1] = max(jugad[i - 1][0], jugad[i - 1][2]) + brr[i]
	jugad[i][2] = max(jugad[i - 1][0], max(jugad[i - 1][1], jugad[i - 1][2]))
print(max(jugad[n - 1][0], max(jugad[n - 1][1], jugad[n - 1][2])))


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


from sys import stdin, stdout
for _ in range(1):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	dp = [[0 for _ in range(2)] for _ in range(n)]
	dp[0][0] = a[0]
	dp[0][1] = b[0]
	for i in range(1, n):
		dp[i][0] = max(a[i] + dp[i - 1][1], dp[i - 1][0])
		dp[i][1] = max(b[i] + dp[i - 1][0], dp[i - 1][1])
	print(max(dp[-1]))


n = int(input())
heights1 = [int(ele) for ele in input().split(' ')]
heights2 = [int(ele) for ele in input().split(' ')]
bestdp1 = [0] * n
bestdp2 = [0] * n
bestdp1[0] = heights1[0]
bestdp2[0] = heights2[0]
for index in range(1, n):
	bestdp1[index] = max(bestdp2[max(index - 3, 0):index]) + heights1[index]
	bestdp2[index] = max(bestdp1[max(index - 3, 0):index]) + heights2[index]
print(max(max(bestdp1), max(bestdp2)))


n = int(input())
h_one = list(map(int, input().split()))
h_two = list(map(int, input().split()))
(one_result, two_result) = (0, 0)
for i in range(n):
	(one_result, two_result) = (max(one_result, two_result + h_one[i]), max(two_result, one_result + h_two[i]))
print(max(one_result, two_result))


n = int(input())
lst1 = [int(i) for i in input().split()]
lst2 = [int(i) for i in input().split()]
(a, b) = (0, 0)
for (x, y) in zip(lst1, lst2):
	(a, b) = (max(a, b + x), max(b, a + y))
print(max(a, b))


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l = []
a = b = 0
for i in range(n):
	l.append((l1[i], l2[i]))
(su0, su1) = l[0]
for i in range(1, n):
	(a, b, su0, su1) = (su0, su1, max(b, su1) + l[i][0], max(a, su0) + l[i][1])
print(max(su0, su1))


n = int(input())
a = [[int(i) for i in input().split()] for j in range(2)]
d = [0, 0]
for i in range(n):
	next = [max(d[0], d[1] + a[0][i]), max(d[1], d[0] + a[1][i])]
	d = next
print(max(d))


n = int(input())
arr_1 = list(map(int, input().split()))
arr_2 = list(map(int, input().split()))
if n == 1:
	print(max(arr_1[0], arr_2[0]))
else:
	dp_1 = []
	dp_2 = []
	dp_1.append(max(arr_1[0] + arr_2[1], arr_2[0]))
	dp_2.append(max(arr_2[0] + arr_1[1], arr_1[0]))
	temp_1 = 1
	temp_2 = 2
	for i in range(2, n, 2):
		if i == n - 1:
			index = int(i / 2) - 1
			dp_1.append(dp_2[index] + arr_2[i])
			dp_2.append(dp_1[index] + arr_1[i])
		else:
			index = int(i / 2) - 1
			dp_1.append(max(dp_2[index] + arr_2[i + 1], dp_1[index] + arr_1[i] + arr_2[i + 1], dp_2[index] + arr_2[i]))
			dp_2.append(max(dp_1[index] + arr_1[i + 1], dp_2[index] + arr_2[i] + arr_1[i + 1], dp_1[index] + arr_1[i]))
	print(max(dp_1[-1], dp_2[-1]))


R = lambda : map(int, input().split())
n = int(input())
a = b = c = d = 0
for (x, y) in zip(R(), R()):
	(a, b, c, d) = (c, d, max(x + b, x + d), max(y + a, y + c))
print(max(c, d))


import sys

def main():
	n = int(sys.stdin.readline().strip())
	r1 = [int(s) for s in sys.stdin.readline().strip().split()]
	r2 = [int(s) for s in sys.stdin.readline().strip().split()]
	r1_max = 0
	r2_max = 0
	for (p1, p2) in zip(r1, r2):
		v1 = max(r1_max, r2_max + p1)
		v2 = max(r2_max, r1_max + p2)
		(r1_max, r2_max) = (v1, v2)
	print(max(r1_max, r2_max))
main()


import sys
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
n = int(ri())
a = RI()
b = RI()
dpa = [0] * (len(a) + 1)
dpb = [0] * (len(a) + 1)
for i in range(len(a)):
	if i == 0:
		dpa[1] = a[i]
		dpb[1] = b[i]
	else:
		dpa[i + 1] = max(dpb[i - 1] + a[i], dpb[i] + a[i])
		dpb[i + 1] = max(dpa[i - 1] + b[i], dpa[i] + b[i])
print(max(dpa[n], dpb[n]))


dp = {}
n = int(input())
h1 = input().split()
for i in range(n):
	h1[i] = int(h1[i])
h2 = input().split()
for i in range(n):
	h2[i] = int(h2[i])
dp[n - 1, 1] = h1[i]
dp[n - 1, 2] = h2[i]
for i in range(n - 2, -1, -1):
	dp[i, 1] = max(h1[i] + dp[i + 1, 2], dp[i + 1, 1])
	dp[i, 2] = max(h2[i] + dp[i + 1, 1], dp[i + 1, 2])
print(max(dp[0, 1], dp[0, 2]))


n = int(input())
a = [int(item) for item in input().split()]
b = [int(item) for item in input().split()]
dp = [[0] * n for _ in range(2)]
dp[0][0] = a[0]
dp[1][0] = b[0]
for i in range(1, n):
	if i == 1:
		dp[0][i] = dp[1][i - 1] + a[i]
		dp[1][i] = dp[0][i - 1] + b[i]
		continue
	dp[0][i] = max(dp[1][i - 1] + a[i], dp[1][i - 2] + a[i])
	dp[1][i] = max(dp[0][i - 1] + b[i], dp[0][i - 2] + b[i])
print(max(dp[0][-1], dp[1][-1]))


import sys
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
hx = int_array()
hy = int_array()
dp = [[-1 for _ in range(3)] for __ in range(n)]
for i in range(n):
	for j in range(3):
		if i == 0:
			if j == 0:
				dp[i][j] = hx[i]
			elif j == 1:
				dp[i][j] = hy[i]
			else:
				dp[i][j] = 0
		elif j == 0:
			dp[i][j] = hx[i] + max(dp[i - 1][j + 1], dp[i - 1][j + 2])
		elif j == 1:
			dp[i][j] = hy[i] + max(dp[i - 1][j + 1], dp[i - 1][j - 1])
		else:
			dp[i][j] = 0 + max(dp[i - 1])
print(max(dp[n - 1]))


n = int(input())
h_t = list(map(int, input().split()))
h_b = list(map(int, input().split()))
dp_t = [0, h_t[0]]
dp_b = [0, h_b[0]]
if n > 1:
	for i in range(1, n):
		dp_t.append(max(dp_b[-1], dp_b[-2]) + h_t[i])
		dp_b.append(max(dp_t[-2], dp_t[-3]) + h_b[i])
print(max(dp_t[-1], dp_b[-1]))


n = int(input())
row = [list(map(int, input().split())), list(map(int, input().split()))]
maX = [row[0][0], row[1][0]]
for i in range(1, n):
	curr = [maX[1] + row[0][i], maX[0] + row[1][i]]
	if curr[0] > maX[0]:
		maX[0] = curr[0]
	if curr[1] > maX[1]:
		maX[1] = curr[1]
print(max(maX[0], maX[1]))


try:
	while True:
		n = int(input())
		dp = [[0] * 100005 for _ in range(2)]
		a = [[0] * n for _ in range(2)]
		a[0] = list(map(int, input().split()))
		a[0].insert(0, 0)
		a[1] = list(map(int, input().split()))
		a[1].insert(0, 0)
		for i in range(1, n + 1):
			dp[0][i] = max(dp[1][i - 1] + a[0][i], dp[0][i - 1])
			dp[1][i] = max(dp[0][i - 1] + a[1][i], dp[1][i - 1])
		print(max(dp[0][n], dp[1][n]))
except EOFError:
	pass


import sys

def input():
	return sys.stdin.readline().strip()

def dinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rt(a, s):
	t = ''
	for i in range(len(s)):
		t = t + a[i] + s[i]
	return int(t)

def main():
	n = dinput()
	a = list(rinput())
	s = list(rinput())
	q1 = [0] * n
	q2 = [0] * n
	q1[0] = a[0]
	q2[0] = s[0]
	m1 = a[0]
	m2 = s[0]
	for i in range(1, n):
		q1[i] = m2 + a[i]
		q2[i] = s[i] + m1
		if q1[i] > m1:
			m1 = q1[i]
		if q2[i] > m2:
			m2 = q2[i]
	print(max(q1[-1], q2[-1]))
main()


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
if n == 1:
	print(max(h1[0], h2[0]))
elif n == 2:
	print(max(h1[0] + h2[1], h1[1] + h2[0]))
else:
	j = 2
	c1 = h1[0] + h2[1]
	c2 = h1[1] + h2[0]
	c3 = h1[0]
	c4 = h2[0]
	for i in range(j, n):
		(c1, c2, c3, c4) = (max(c2, c3) + h2[i], max(c1, c4) + h1[i], c2, c1)
	print(max(c1, c2, c3, c4))


from sys import stdin
for s in stdin:
	n = int(s)
	inp = [list(map(int, input().split())) for __ in range(2)]
	d = [0, 0]
	for i in range(n):
		d = [max(d[0], d[1] + inp[0][i]), max(d[1], d[0] + inp[1][i])]
	print(max(d[0], d[1]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dp = [0] * len(a)
dp1 = [0] * len(a)
dp[0] = a[0]
dp1[0] = b[0]
if n >= 2:
	dp[1] = a[1] + b[0]
	dp1[1] = b[1] + a[0]
for j in range(2, n):
	dp[j] = max(dp1[j - 1], max(dp[j - 2], dp1[j - 2])) + a[j]
	dp1[j] = max(dp[j - 1], max(dp[j - 2], dp1[j - 2])) + b[j]
print(max(dp[-1], dp1[-1]))


from sys import stdin
input = stdin.readline
n = int(input())
h_1 = [int(i) for i in input().split()]
h_2 = [int(i) for i in input().split()]
max_h = [[0 for i in range(n)] for j in range(2)]
max_h[0][0] = h_1[0]
max_h[1][0] = h_2[0]
if n > 1:
	max_h[0][1] = h_1[1] + h_2[0]
	max_h[1][1] = h_2[1] + h_1[0]
for i in range(2, n):
	max_h[0][i] = h_1[i] + max([max_h[1][i - 1], max_h[1][i - 2]])
	max_h[1][i] = h_2[i] + max([max_h[0][i - 1], max_h[0][i - 2]])
print(max([max_h[0][n - 1], max_h[1][n - 1]]))


from sys import stdin

def solve(n, row1, row2):
	dp = [[-1] * 3 for i in range(n)]
	dp[0][0] = 0
	dp[0][1] = row1[0]
	dp[0][2] = row2[0]
	for i in range(1, n):
		dp[i][0] = max(dp[i - 1])
		dp[i][1] = row1[i] + max(dp[i - 1][0], dp[i - 1][2])
		dp[i][2] = row2[i] + max(dp[i - 1][0], dp[i - 1][1])
	return max(dp[n - 1])
n = int(stdin.readline())
row1 = list(map(int, stdin.readline().split(' ')))
row2 = list(map(int, stdin.readline().split(' ')))
print(solve(n, row1, row2))


from sys import stdin
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
n = I()
(a, b) = (list(R()), list(R()))
(x, y) = (0, 0)
for i in range(n):
	(x, y) = (max(x, y + a[i]), max(y, x + b[i]))
print(max(x, y))


import sys
input = lambda : sys.stdin.readline().strip()
from math import *
n = int(input())
ls1 = list(map(int, input().split()))
ls2 = list(map(int, input().split()))
dp = []
for i in range(n):
	dp.append([0, 0, 0])
dp[n - 1][0] = 0
dp[n - 1][1] = ls1[-1]
dp[n - 1][2] = ls2[-1]
for i in range(n - 2, -1, -1):
	dp[i][0] = max(dp[i + 1][0], dp[i + 1][1], dp[i + 1][2])
	dp[i][1] = max(dp[i + 1][0], dp[i + 1][2]) + ls1[i]
	dp[i][2] = max(dp[i + 1][0], dp[i + 1][1]) + ls2[i]
print(max(dp[0][0], dp[0][1], dp[0][2]))


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
h = [h1, h2]
dp = []
for i in range(2):
	dp.append([0] * (n + 1))
for i in range(n):
	for j in range(2):
		dp[j][i + 1] = max(dp[j][i], dp[1 - j][i] + h[j][i])
print(max(dp[0][n], dp[1][n]))


n = int(input())
l = [list(map(int, input().split())), list(map(int, input().split()))]
c = [[l[i][j] for j in range(n)] for i in range(2)]
for i in range(n - 1, -1, -1):
	for j in range(0, 2):
		if i == n - 1:
			c[j][i] = l[j][i]
			continue
		v = [l[j][i]]
		if i + 1 < n:
			v.append(c[j ^ 1][i + 1] + l[j][i])
		if i + 2 < n:
			v.append(c[j ^ 1][i + 2] + l[j][i])
		c[j][i] = max(v)
print(max(c[0][0], c[1][0]))


n = int(input())
x1 = list(map(int, input().split()))
x2 = list(map(int, input().split()))
dp = [[0] * 2 for i in range(100000)]
for i in range(n):
	if i == 0:
		dp[0][0] = x1[0]
		dp[0][1] = x2[0]
	elif i == 1:
		dp[1][0] = x1[1] + dp[0][1]
		dp[1][1] = x2[1] + dp[0][0]
	else:
		dp[i][0] = x1[i] + max(dp[i - 1][1], dp[i - 2][1])
		dp[i][1] = x2[i] + max(dp[i - 1][0], dp[i - 2][0])
print(max(dp[n - 1][0], dp[n - 1][1]))


from sys import stdin, stdout

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

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

def ip():
	return int(stdin.readline())

def op(ans):
	return stdout.write(str(ans) + '\n')
n = ip()
first = ai()
second = ai()
dp1 = first[0]
dp2 = second[0]
for i in range(1, n):
	(dp1, dp2) = (max(dp1, dp2 + first[i]), max(dp2, second[i] + dp1))
op(max(dp1, dp2))


def gns():
	return list(map(int, input().split()))
n = int(input())
ps = []
ps.append(gns())
ps.append(gns())
dp = [[0] * 2 for i in range(n)]

def get(i, t):
	if i < 0:
		return 0
	else:
		return dp[i][t]
ans = 0
for i in range(n):
	for t in range(2):
		mx = max(get(i - 1, 1 - t), get(i - 2, 1 - t))
		dp[i][t] = mx + ps[t][i]
		ans = max(ans, dp[i][t])
print(ans)


n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
A = a[n - 1]
B = b[n - 1]
for i in range(n - 2, -1, -1):
	lA = A
	lB = B
	A = max(a[i] + lB, lA)
	B = max(b[i] + lA, lB)
print(max(A, B))


import sys
input = sys.stdin.readline
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
put1 = [a1[0]]
put2 = [a2[0]]
if n > 1:
	put1.append(put2[0] + a1[1])
	put2.append(put1[0] + a2[1])
for i in range(2, n):
	p1 = max(put2[i - 1], put2[i - 2], put2[i - 3]) + a1[i]
	p2 = max(put1[i - 1], put1[i - 2], put1[i - 3]) + a2[i]
	put1.append(p1)
	put2.append(p2)
print(max(max(put1), max(put2)))


def answer(n, A, B):
	dp = [[0 for i in range(n)] for j in range(2)]
	dp[0][0] = A[0]
	dp[1][0] = B[0]
	for i in range(1, n):
		dp[0][i] = max(dp[0][i - 1], dp[1][i - 1] + A[i])
		dp[1][i] = max(dp[1][i - 1], dp[0][i - 1] + B[i])
	return max(dp[0][-1], dp[1][-1])
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
print(answer(n, A, B))


num_players = int(input())
top_row = list(map(int, input().split()))
bottom_row = list(map(int, input().split()))
if num_players == 1:
	print(max(top_row[0], bottom_row[0]))
else:
	top_solutions = [top_row[0], bottom_row[0] + top_row[1]]
	bottom_solutions = [bottom_row[0], top_row[0] + bottom_row[1]]
	for player in range(2, num_players):
		top_solutions.append(max(top_row[player] + bottom_solutions[player - 1], top_row[player] + bottom_solutions[player - 2]))
		bottom_solutions.append(max(bottom_row[player] + top_solutions[player - 1], bottom_row[player] + top_solutions[player - 2]))
	print(max(top_solutions[-1], bottom_solutions[-1]))


import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
N = int(input())
A = []
for _ in range(2):
	a = list(map(int, input().split()))
	A.append(a)
dp = [[[0] * N for _ in range(2)] for _ in range(2)]
dp[0][0][0] = 0
dp[0][1][0] = A[1][0]
dp[1][0][0] = A[0][0]
dp[1][1][0] = 0
for k in range(1, N):
	for i in range(2):
		for j in range(2):
			dp[i][j][k] = max(dp[i][j][k], dp[i][j][k - 1])
			if i != j:
				dp[i][j][k] = max(dp[i][j][k], dp[i ^ 1][j ^ 1][k - 1] + A[i ^ 1][k])
			else:
				dp[i][j][k] = max(dp[i][j][k], dp[i ^ 1][j ^ 1][k - 1] + A[i][k], dp[i][j ^ 1][k - 1] + A[i][k])
ans = 0
for i in range(2):
	for j in range(2):
		ans = max(ans, dp[i][j][-1])
print(ans)


n = int(input())
a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]
dp = [[-1] * 2 for s in range(n + 1)]
dp[1][0] = a[0]
dp[1][1] = b[0]
for i in range(2, n + 1):
	dp[i][0] = max(dp[i - 1][1] + a[i - 1], dp[i - 1][0])
	dp[i][1] = max(dp[i - 1][0] + b[i - 1], dp[i - 1][1])
print(max(dp[n][0], dp[n][1]))


n = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
dp = [[0 for _ in range(3)] for _ in range(n + 1)]
for j in range(3):
	dp[0][j] = 0
dp[1][0] = A[0]
dp[1][1] = B[0]
dp[1][2] = 0
for i in range(2, n + 1):
	for j in range(3):
		if j == 0:
			dp[i][j] = A[i - 1] + max(dp[i - 1][1], dp[i - 1][2])
		elif j == 1:
			dp[i][j] = B[i - 1] + max(dp[i - 1][0], dp[i - 1][2])
		else:
			dp[i][j] = max(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2])
m = -1
for i in range(n + 1):
	for j in range(3):
		m = max(m, dp[i][j])
print(m)


n = int(input())
a = [list(map(int, input().split())), list(map(int, input().split()))]
m = [a[0][-1], a[1][-1]]
for i in list(range(n - 1))[::-1]:
	(m[0], m[1]) = (max(m[0], m[1] + a[0][i]), max(m[1], m[0] + a[1][i]))
print(max(m[0], m[1]))


n = int(input())
first = list(map(int, input().split()))
second = list(map(int, input().split()))
(no, top, bottom) = (0, 0, 0)
for i in range(n):
	t_no = max(no, top, bottom)
	t_top = first[i] + max(no, bottom)
	t_bottom = second[i] + max(no, top)
	(no, top, bottom) = (t_no, t_top, t_bottom)
print(max(no, top, bottom))


n = int(input())
l = [list(map(int, input().split())) for _ in range(2)]
dp = [[0] * 2 for _ in range(n + 1)]
for i in range(n):
	dp[i + 1][0] = max(dp[i][0], dp[i][1] + l[0][i])
	dp[i + 1][1] = max(dp[i][1], dp[i][0] + l[1][i])
print(max(dp[n]))


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
sum1 = 0
sum2 = 0
for i in range(n):
	(sum1, sum2) = (max(sum1, sum2 + h1[i]), max(sum2, sum1 + h2[i]))
print(max(sum1, sum2))


n = int(input())
s = [int(i) for i in input().split()]
ss = [int(i) for i in input().split()]
dp = [0] * n
dpp = [0] * n
if n > 1:
	for i in range(0, n):
		dp[i] = max(dpp[i - 1], dpp[i - 2]) + s[i]
		dpp[i] = max(dp[i - 1], dp[i - 2]) + ss[i]
	print(max(dp[-1], dpp[-1]))
else:
	print(max(s[0], ss[0]))


n = int(input())
h = []
h.append(list(map(int, input().split())))
h.append(list(map(int, input().split())))
d = []
c = []
b = []
for i in range(n):
	d.append(0)
	c.append(0)
b.append(d)
b.append(c)
b[0][n - 1] = h[0][n - 1]
b[1][n - 1] = h[1][n - 1]
i = n - 2
while i > -1:
	b[0][i] = max(h[0][i] + b[1][i + 1], b[0][i + 1])
	b[1][i] = max(h[1][i] + b[0][i + 1], b[1][i + 1])
	i = i - 1
print(max(b[0][0], b[1][0]))


import sys
from collections import defaultdict

def main():
	n = int(input())
	h1 = list(map(int, input().split()))
	h2 = list(map(int, input().split()))
	res = 0
	dp1 = [0] * n
	dp2 = [0] * n
	dp1[0] = h1[0]
	dp2[0] = h2[0]
	res = max(dp1[0], dp2[0])
	if n > 1:
		dp1[1] = h1[1] + h2[0]
		res = max(res, dp1[1])
		dp2[1] = h2[1] + h1[0]
		res = max(res, dp2[1])
	for i in range(2, n):
		dp1[i] = h1[i] + max(dp2[i - 1], dp2[i - 2])
		res = max(res, dp1[i])
		dp2[i] = h2[i] + max(dp1[i - 1], dp1[i - 2])
		res = max(res, dp2[i])
	print(res)
main()


def fun(n, a, b):
	ans = (a[0], b[0], 0)
	for i in range(1, n):
		ans = (max(ans[1], ans[2]) + a[i], max(ans[0], ans[2]) + b[i], max(ans[0], ans[1]))
	return max(ans)
t = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
print(fun(t, x, y))


n = int(input())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
dp = [[[0] * 2 for _ in range(3)] for _ in range(n)]
dp[0][2][0] = arr1[0]
dp[0][2][1] = arr2[0]
for i in range(1, n):
	dp[i][0][0] = dp[i - 1][1][0]
	dp[i][0][1] = dp[i - 1][1][1]
	dp[i][1][0] = dp[i - 1][2][0]
	dp[i][1][1] = dp[i - 1][2][1]
	dp[i][2][0] = max(arr1[i] + dp[i][0][0], arr1[i] + dp[i][0][1], arr1[i] + dp[i][1][1])
	dp[i][2][1] = max(arr2[i] + dp[i][0][0], arr2[i] + dp[i][0][1], arr2[i] + dp[i][1][0])
print(max(dp[n - 1][2][0], dp[n - 1][2][1]))


n = int(input())
row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))
maxUpper = row1[0]
maxLower = row2[0]
for i in range(1, n):
	tmpUpper = maxUpper
	tmpLower = maxLower
	maxUpper = max(maxUpper, row1[i] + tmpLower)
	maxLower = max(maxLower, row2[i] + tmpUpper)
print(max(maxUpper, maxLower))


n = int(input())
num = []
num.append(list(map(int, input().split())))
num.append(list(map(int, input().split())))
value = []
dp = [[0 for _ in range(n)] for _ in range(2)]
dp[0][0] = num[0][0]
dp[1][0] = num[1][0]
for i in range(1, n):
	dp[0][i] = max(dp[0][i - 1], num[0][i] + dp[1][i - 1])
	dp[1][i] = max(dp[1][i - 1], num[1][i] + dp[0][i - 1])
print(max(dp[0][n - 1], dp[1][n - 1]))


CHOSE_A = 0
CHOSE_B = 1
CHOSE_NEITHER = 2
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
memo = []
for i in range(n):
	memo.append([-1, -1, -1])
chose_b = a[n - 1]
chose_a = b[n - 1]
chose_neither = max(a[n - 1], b[n - 1])
for i in range(n - 2, -1, -1):
	choose_a = max(b[i] + chose_b, chose_neither)
	choose_b = max(a[i] + chose_a, chose_neither)
	choose_neither = max(a[i] + chose_a, b[i] + chose_b, chose_neither)
	chose_a = choose_a
	chose_b = choose_b
	chose_neither = choose_neither
print(chose_neither)


n = int(input())
r_1 = list(map(int, input().split(' ')))
r_2 = list(map(int, input().split(' ')))
a_0 = 0
b_0 = 0
a_1 = r_1[0]
b_1 = r_2[0]
for i in range(1, n):
	a_2 = r_1[i] + max(b_1, b_0)
	b_2 = r_2[i] + max(a_0, a_1)
	(a_0, a_1, b_0, b_1) = (a_1, a_2, b_1, b_2)
print(max(a_1, b_1))


from collections import Counter, defaultdict, deque
from math import factorial as fact
n = int(input())
a1 = [int(x) for x in input().split()]
a2 = [int(x) for x in input().split()]
dp1 = [-1] * n
dp2 = [-1] * n
dp1[0] = a1[0]
dp2[0] = a2[0]
for i in range(1, n):
	dp1[i] = max(dp1[i - 1], dp2[i - 1] + a1[i])
	dp2[i] = max(dp2[i - 1], dp1[i - 1] + a2[i])
print(max(dp1[-1], dp2[-1]))


def dp_solve(h):
	n = len(h[0])
	memo = {}

	def solve(r, c):
		if (r, c) in memo.keys():
			return memo[r, c]
		if c == n - 1:
			return h[r][c]
		elif c == n - 2:
			return h[r][c] + h[1 - r][c + 1]
		else:
			m = h[r][c] + max(solve(1 - r, c + 1), solve(1 - r, c + 2))
			memo[r, c] = m
			return m
	for i in range(n):
		solve(0, n - 1 - i)
		solve(1, n - 1 - i)
	return max(solve(0, 0), solve(1, 0))
n = int(input())
h = []
for i in range(2):
	h.append([int(x) for x in input().split(' ')])
print(dp_solve(h))


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
rek = [[0 for i in range(3)] for j in range(n + 1)]
for index in range(n):
	for rinda in range(3):
		if rinda == 1:
			nootras = rek[index - 1][2] + l1[index]
			nenovienas = rek[index - 1][0] + l1[index]
			rek[index][rinda] = max(nootras, nenovienas)
		if rinda == 2:
			nopirmas = rek[index - 1][1] + l2[index]
			nenovienas = rek[index - 1][0] + l2[index]
			rek[index][rinda] = max(nopirmas, nenovienas)
		if rinda == 0:
			nopirmas = rek[index - 1][1]
			nootras = rek[index - 1][2]
			rek[index][rinda] = max(nootras, nopirmas)
nopirmas = rek[n - 1][1]
notras = rek[n - 1][2]
abas = rek[n - 1][0]
print(max(nopirmas, notras, abas))


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
dp1 = [0] * len(l1)
dp2 = [0] * len(l2)
dp1[0] = l1[0]
dp2[0] = l2[0]
if n >= 2:
	dp1[1] = l2[0] + l1[1]
	dp2[1] = l1[0] + l2[1]
	for i in range(2, n):
		dp1[i] = max(dp2[i - 1], max(dp1[i - 2], dp2[i - 2])) + l1[i]
		dp2[i] = max(dp1[i - 1], max(dp1[i - 2], dp2[i - 2])) + l2[i]
print(max(dp1[-1], dp2[-1]))


R = lambda : map(int, input().split())
input()
a = b = 0
for (x, y) in zip(R(), R()):
	(a, b) = (max(a, b + x), max(b, a + y))
print(max(a, b))


from sys import stdin
n = int(stdin.readline())
h = [[], []]
h[0] = list(map(int, stdin.readline().split(' ')))
h[1] = list(map(int, stdin.readline().split(' ')))
dp = [[0 for i in range(n)], [0 for i in range(n)]]
dp[0][0] = h[0][0]
dp[1][0] = h[1][0]
for j in range(1, n):
	for i in [0, 1]:
		dp[i][j] = max(dp[i][j - 1], h[i][j] + dp[i ^ 1][j - 1])
res = max(dp[0][n - 1], dp[1][n - 1])
print(res)


n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
(ma, mi, last) = (max(a1[0], a2[0]), min(a1[0], a2[0]), 0 if a1[0] > a2[0] else 1)
a3 = []
for i in range(n):
	a3.append(a1[i])
	a3.append(a2[i])
for i in range(2, 2 * n):
	if i == 2:
		a3[i] += a3[1]
	elif i == 3:
		a3[i] += a3[0]
	elif i % 2 == 0:
		a3[i] += max(a3[i - 1], a3[i - 3])
	else:
		a3[i] += max(a3[i - 3], a3[i - 5])
print(max(a3[-1], a3[-2]))


I = lambda : map(int, input().split())
(n,) = I()
a = (*I(),)
b = (*I(),)
c = d = i = 0
while i < n:
	(c, d) = (max(d + a[i], c), max(c + b[i], d))
	i += 1
print(max(c, d))


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
(a1, a2) = (0, 0)
for i in range(n):
	(a1, a2) = (max(a1, a2 + l1[i]), max(a2, a1 + l2[i]))
print(max(a1, a2))


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
from heapq import heappush as hpush
from heapq import heappop as hpop
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
n = ri(1)
a = ri()
b = ri()
dp = [[0, 0] for i in range(n)]
dp[0][0] = a[0]
dp[0][1] = b[0]
for i in range(1, n):
	dp[i][0] = max(dp[i - 1][0], dp[i - 1][1] + a[i])
	dp[i][1] = max(dp[i - 1][1], dp[i - 1][0] + b[i])
print(max(dp[n - 1][0], dp[n - 1][1]))


n = int(input())
h1 = []
h2 = []
for c in input().split():
	h1.append(int(c))
for c in input().split():
	h2.append(int(c))
max_ht = [[0] * 3 for i in range(n)]
max_ht[0][0] = h1[0]
max_ht[0][1] = h2[0]
for i in range(1, n):
	max_ht[i][0] = max(max_ht[i - 1][1], max_ht[i - 1][2]) + h1[i]
	max_ht[i][1] = max(max_ht[i - 1][0], max_ht[i - 1][2]) + h2[i]
	max_ht[i][2] = max(max_ht[i - 1][0], max(max_ht[i - 1][1], max_ht[i - 1][2]))
print(max(max_ht[n - 1][0], max(max_ht[n - 1][1], max_ht[n - 1][2])))


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
if n == 1:
	print(max(h1[0], h2[0]))
else:
	a = [0] * n
	b = [0] * n
	a[0] = h1[0]
	b[0] = h2[0]
	a[1] = b[0] + h1[1]
	b[1] = a[0] + h2[1]
	i = 2
	while i < n:
		a[i] = h1[i] + max(b[i - 1], b[i - 2])
		b[i] = h2[i] + max(a[i - 1], a[i - 2])
		i += 1
	print(max(a[-1], b[-1]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
r1 = 0
r2 = 0
for i in range(n):
	(r1, r2) = (max(r2 + a[i], r1), max(r1 + b[i], r2))
print(max(r1, r2))


from itertools import repeat
import sys
dp = None
n = None
arr = None

def func(ind, row):
	if ind == n:
		return 0
	if dp[row][ind] != -1:
		return dp[row][ind]
	dp[row][ind] = max(func(ind + 1, row), arr[row][ind] + func(ind + 1, row ^ 1))
	return dp[row][ind]

def solve():
	global n, dp, arr
	n = int(input())
	up = [int(x) for x in input().split()]
	down = [int(x) for x in input().split()]
	arr = [up, down]
	dp = [list(repeat(-1, n)), list(repeat(-1, n))]
	for i in reversed(range(n)):
		func(i, 0)
		func(i, 1)
	print(max(func(0, 0), func(0, 1)))
solve()


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
ans1 = [0] * n
ans2 = [0] * n
ans1[0] = l1[0]
ans2[0] = l2[0]
for i in range(1, n):
	ans1[i] = max(ans1[i - 1], ans2[i - 1] + l1[i])
	ans2[i] = max(ans2[i - 1], ans1[i - 1] + l2[i])
print(max(ans1[n - 1], ans2[n - 1]))


def solve():
	n = int(input())
	h = [[0 for i in range(n)], [0 for i in range(n)]]
	h[0] = list(map(int, input().split()))
	h[1] = list(map(int, input().split()))
	dp = [[0, 0] for i in range(n)]
	for i in range(n):
		if i == 0:
			dp[i][0] = h[0][0]
			dp[i][1] = h[1][0]
			continue
		for j in range(2):
			dp[i][j] = dp[i - 1][j]
			dp[i][j] = max(dp[i][j], h[j][i] + dp[i - 1][1 - j])
	print(max(dp[n - 1][0], dp[n - 1][1]))
solve()


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
(mx1r, mx2r) = (0, 0)
(mx1, mx2) = (0, 0)
for (i, j) in zip(il(), il()):
	mx1 = max(mx2r + i, mx1r)
	mx2 = max(mx1r + j, mx2r)
	(mx1r, mx2r) = (mx1, mx2)
print(max(mx1, mx2))


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
I = sys.stdin.readline

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				return False
		return True

def main():
	n = ii()
	h1 = li()
	h2 = li()
	dp1 = [0] * (n + 1)
	dp2 = [0] * (n + 1)
	for i in range(1, n + 1):
		dp1[i] = max(dp1[i - 1], dp2[i - 1] + h1[i - 1])
		dp2[i] = max(dp2[i - 1], dp1[i - 1] + h2[i - 1])
	print(max(dp2[n], dp1[n]))
main()


n = int(input())
i1 = list(map(int, input().split()))
i2 = list(map(int, input().split()))
o1 = [0] * n
o2 = [0] * n
o1[0] = i1[0]
o2[0] = i2[0]
for i in range(1, n):
	o1[i] = max(o1[i - 1] - i1[i - 1], o2[i - 1]) + i1[i]
	o2[i] = max(o2[i - 1] - i2[i - 1], o1[i - 1]) + i2[i]
print(max(o1[n - 1], o2[n - 1]))


maxe = 0

def recur(arr, m, n, flag):
	global maxe
	if m >= len(arr):
		if n > maxe:
			maxe = n
		return 0
	return recur(arr, m + 1, n, flag) + recur(arr, m + 1, n + arr[m][flag], 1 - flag)
n = int(input())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
arr = []
d = [[0 for i in range(2)] for j in range(n + 1)]
for i in range(n):
	arr.append([arr1[i], arr2[i]])
for i in range(1, n + 1):
	for j in range(2):
		d[i][j] = max(d[i - 1][1 - j] + arr[i - 1][j], d[i - 1][j])
print(max(d[n][0], d[n][1]))


n = int(input())
l = list(map(int, input().strip().split()))
m = list(map(int, input().strip().split()))
a = []
for i in range(n):
	a.append(l[i])
	a.append(m[i])
dp = [[l[0], False], [m[0], True]]
counter = False
m = max(dp[-1][0], dp[-2][0])
for i in range(2, 2 * n):
	if not counter:
		dp.append([max(dp[i - 1][0] + a[i], dp[i - 2][0]), counter])
		m = max(m, dp[-1][0])
		counter = not counter
	else:
		dp.append([max(dp[i - 2][0], dp[i - 3][0] + a[i]), counter])
		m = max(m, dp[-1][0])
		counter = not counter
print(m)


import random
import math
from collections import defaultdict
import itertools
from sys import stdin, stdout
import sys
import operator

def main():
	z = ''
	n = int(input())
	h1 = list(map(int, input().split()))
	h2 = list(map(int, input().split()))
	dp = [[0 for _ in range(4)] for _ in range(n + 1)]
	for i in range(1, n + 1):
		dp[i][0] = dp[i - 1][1]
		dp[i][1] = h1[i - 1] + max(dp[i - 1][3], dp[i - 1][2])
		dp[i][2] = h2[i - 1] + max(dp[i - 1][0], dp[i - 1][1])
		dp[i][3] = dp[i - 1][2]
	print(max(dp[-1]))
main()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(h1, h2) = (0, 0)
for (x, y) in zip(a, b):
	(h1, h2) = (max(h1, h2 + x), max(h2, h1 + y))
print(max(h1, h2))


n = int(input())
h1 = [int(x) for x in input().split()]
h2 = [int(x) for x in input().split()]
h = [h1, h2]
(x, y, z) = (h[0][0], h[1][0], 0)
for i in range(1, n):
	temp1 = x
	temp2 = y
	temp3 = z
	x = max(temp2 + h[0][i], temp3 + h[0][i], h[0][i])
	y = max(temp1 + h[1][i], temp3 + h[1][i], h[1][i])
	z = max(temp1, temp2)
print(max(x, y, z))


n = int(input())
str1 = input().split()
str2 = input().split()
str1 = [int(i) for i in str1]
str2 = [int(i) for i in str2]
arr1 = str1.copy()
arr2 = str2.copy()
if n > 1:
	arr1[1] += arr2[0]
	arr2[1] += arr1[0]
for i in range(2, n):
	add1 = max(arr2[i - 2], arr2[i - 1])
	add2 = max(arr1[i - 2], arr1[i - 1])
	arr1[i] += add1
	arr2[i] += add2
print(max(arr1[-1], arr2[-1]))


n = int(input())
L0 = [int(x) for x in input().split()]
L1 = [int(x) for x in input().split()]
if n == 1:
	print(max(L0[0], L1[0]))
else:
	dp = [[0, 0] for i in range(n)]
	dp[0][0] = L0[0]
	dp[0][1] = L1[0]
	dp[1][0] = dp[0][1] + L0[1]
	dp[1][1] = dp[0][0] + L1[1]
	for i in range(1, n):
		dp[i][0] = max(dp[i - 1][1], dp[i - 2][1]) + L0[i]
		dp[i][1] = max(dp[i - 1][0], dp[i - 2][0]) + L1[i]
	print(max(dp[n - 1][0], dp[n - 1][1]))


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
if n > 1:
	h12 = [0] * n
	h22 = [0] * n
	h12[0] = h1[0]
	h22[0] = h2[0]
	h12[1] = max(h12[0], h22[0] + h1[1])
	h22[1] = max(h22[0], h12[0] + h2[1])
	for i in range(2, n):
		h12[i] = max(h12[i - 1], h22[i - 1] + h1[i])
		h22[i] = max(h22[i - 1], h12[i - 1] + h2[i])
		h12[i] = max(h12[i], h22[i - 2] + h1[i])
		h22[i] = max(h22[i], h12[i - 2] + h2[i])
	print(max(h12[-1], h22[-1]))
else:
	print(max(h1[0], h2[0]))


def main():
	n = int(input())
	h1 = list(map(int, input().split()))
	h2 = list(map(int, input().split()))
	dp1 = [0] * n
	dp2 = [0] * n
	dp1[0] = h1[0]
	dp2[0] = h2[0]
	max1 = h1[0]
	max2 = h2[0]
	for i in range(1, n):
		app1 = max2 + h1[i]
		app2 = max1 + h2[i]
		max1 = max(max1, app1)
		max2 = max(max2, app2)
		dp1[i] = app1
		dp2[i] = app2
	print(max(dp1[-1], dp2[-1]))
main()


def basketball_team(n, heights1, heights2):
	cache1 = [None for __ in range(n)]
	cache2 = [None for __ in range(n)]
	for idx in range(n - 1, -1, -1):
		if idx == n - 1:
			cache1[idx] = heights1[idx]
			cache2[idx] = heights2[idx]
		elif idx == n - 2:
			cache1[idx] = heights1[idx] + heights2[idx + 1]
			cache2[idx] = heights2[idx] + heights1[idx + 1]
		else:
			cache1[idx] = heights1[idx] + max(cache2[idx + 1], cache2[idx + 2])
			cache2[idx] = heights2[idx] + max(cache1[idx + 1], cache1[idx + 2])
	return max(cache1[0], cache2[0])
n = int(input())
heights1 = list(map(int, input().split()))
heights2 = list(map(int, input().split()))
print(basketball_team(n, heights1, heights2))


inputs = int(input())
row1 = input().split()
row2 = input().split()
up = 1
down = 2
i = 0
for element in row1:
	row1[i] = int(element)
	i += 1
i = 0
for element in row2:
	row2[i] = int(element)
	i += 1
i = 0
temp = [0, 0, 0]
prev = []
for i in range(inputs):
	prev.append([0, 0, 0])
for i in range(inputs):
	if i == 0:
		prev[i][0] = 0
		prev[i][up] = row1[i]
		prev[i][down] = row2[i]
	else:
		if prev[i - 1][up] > prev[i - 1][down]:
			prev[i][0] = prev[i - 1][up]
		else:
			prev[i][0] = prev[i - 1][down]
		if prev[i - 1][up] + row2[i] > prev[i - 1][0] + row2[i]:
			prev[i][down] = prev[i - 1][up] + row2[i]
		else:
			prev[i][down] = prev[i - 1][0] + row2[i]
		if prev[i - 1][down] + row1[i] > prev[i - 1][0] + row1[i]:
			prev[i][up] = prev[i - 1][down] + row1[i]
		else:
			prev[i][up] = prev[i - 1][0] + row1[i]
print(sorted(prev[i])[2])


n = int(input())
row = [[]]
row.append(list(map(int, input().split())))
row.append(list(map(int, input().split())))
dp = [[None] * 3 for i in range(n + 7)]

def compute(i, idx):
	take_0 = dp[i + 1][0]
	take_1 = row[1][i] + dp[i + 1][1]
	take_2 = row[2][i] + dp[i + 1][2]
	if idx == 0:
		dp[i][idx] = max(take_0, max(take_1, take_2))
	elif idx == 1:
		dp[i][idx] = max(take_0, take_2)
	else:
		dp[i][idx] = max(take_0, take_1)
dp[n - 1][0] = max(row[1][n - 1], row[2][n - 1])
dp[n - 1][1] = row[2][n - 1]
dp[n - 1][2] = row[1][n - 1]
for j in range(n - 2, -1, -1):
	for i in range(3):
		compute(j, i)
print(dp[0][0])


N = int(input())
A = input().split()
A = list(map(int, A))
B = input().split()
B = list(map(int, B))
dym = [[0, 0] for i in range(N)]
for i in range(N):
	if i == 0:
		dym[i][0] = A[0]
		dym[i][1] = B[0]
	elif i == 1:
		dym[i][0] = A[1] + B[0]
		dym[i][1] = A[0] + B[1]
	else:
		dym[i][0] = A[i] + max(dym[i - 1][1], dym[i - 2][1])
		dym[i][1] = B[i] + max(dym[i - 1][0], dym[i - 2][0])
print(max(dym[-1][0], dym[-1][1]))


n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
if n == 1:
	print(max(x[0], y[0]))
else:
	x[-2] += y[-1]
	y[-2] += x[-1]
	for i in range(3, n + 1):
		x[-i] += max(y[-i + 1], y[-i + 2])
		y[-i] += max(x[-i + 1], x[-i + 2])
	print(max(x[0], y[0]))


n = int(input())
ao = list(map(int, input().split()))
bo = list(map(int, input().split()))
if n == 1:
	print(max(ao[0], bo[0]))
elif n == 2:
	print(max(ao[0] + bo[1], ao[1] + bo[0]))
else:
	a = []
	b = []
	a.extend([ao[0], ao[1] + bo[0]])
	b.extend([bo[0], bo[1] + ao[0]])
	for i in range(2, n):
		a.append(max(ao[i] + b[i - 1], ao[i] + b[i - 2]))
		b.append(max(bo[i] + a[i - 1], bo[i] + a[i - 2]))
	print(max(a[n - 1], b[n - 1]))


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
m = [[-1] * 3 for i in range(n)]
(m[0][0], m[0][1], m[0][2]) = (0, h1[0], h2[0])
for i in range(1, n):
	m[i][0] = max(m[i - 1][0], m[i - 1][1], m[i - 1][2])
	m[i][1] = max(h1[i] + m[i - 1][2], h1[i] + m[i - 1][0])
	m[i][2] = max(h2[i] + m[i - 1][1], h2[i] + m[i - 1][0])
print(max(m[n - 1]))


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)
n = ii()
a = []
a.append(li())
a.append(li())
dp = [[0] * n for i in range(2)]
dp[0][0] = a[0][0]
dp[1][0] = a[1][0]
for i in range(1, n):
	dp[0][i] = max(dp[0][i - 1], a[0][i] + dp[1][i - 1])
	dp[1][i] = max(dp[1][i - 1], a[1][i] + dp[0][i - 1])
print(max(dp[0][-1], dp[1][-1]))


n = int(input())
l = list(map(int, input().split()))
k = list(map(int, input().split()))
maxup = l[-1]
maxdown = k[-1]
for j in range(n - 2, -1, -1):
	val1 = maxup + k[j]
	val2 = maxdown + l[j]
	maxdown = max(val1, maxdown)
	maxup = max(val2, maxup)
print(max(maxup, maxdown))


import sys
import math as mt
import bisect
input = sys.stdin.readline
t = 1

def ncr_util():
	inv[0] = inv[1] = 1
	fact[0] = fact[1] = 1
	for i in range(2, 300001):
		inv[i] = inv[i % p] * (p - p // i) % p
	for i in range(1, 300001):
		inv[i] = inv[i - 1] * inv[i] % p
		fact[i] = fact[i - 1] * i % p

def solve():
	dp = [[0 for j in range(2)] for i in range(n + 1)]
	ans = 0
	dp[0][0] = l1[0]
	dp[0][1] = l2[0]
	ans = max(l1[0], l2[0])
	(max1, max2) = (l1[0], l2[0])
	for i in range(1, n):
		dp[i][0] = max2 + l1[i]
		dp[i][1] = max1 + l2[i]
		max2 = max(max2, dp[i][1])
		max1 = max(max1, dp[i][0])
		ans = max(dp[i][0], dp[i][1], ans)
	return ans
for _ in range(t):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	print(solve())


n = int(input())
a = [list(map(int, input().split())), list(map(int, input().split()))]
res = [[a[0][0]], [a[1][0]]]
if n > 1:
	res[0].append(a[1][0] + a[0][1])
	res[1].append(a[0][0] + a[1][1])
for i in range(2, n):
	res[0].append(max(res[1][-1], res[1][-2]) + a[0][i])
	res[1].append(max(res[0][-2], res[0][-3]) + a[1][i])
print(max(res[0][-1], res[1][-1]))


n = int(input())
l1 = [int(i) for i in input().split()]
l2 = [int(i) for i in input().split()]
maxi_haut = [0]
maxi_bas = [0]
indice = len(l1) - 1
while indice >= 0:
	tmp = l1[indice] + maxi_bas[-1]
	maxi_haut.append(max(maxi_haut[-1], tmp))
	tmp = l2[indice] + maxi_haut[-2]
	maxi_bas.append(max(maxi_bas[-1], tmp))
	indice -= 1
print(max(maxi_bas[-1], maxi_haut[-1]))


def main():
	n = int(input())
	h = [list(map(int, input().split())) for i in range(2)]
	(x, y) = (0, 0)
	for i in range(n):
		(a, b) = (max(x, y + h[0][i]), max(y, x + h[1][i]))
		(x, y) = (a, b)
	print(max(x, y))
main()


import sys
t = int(sys.stdin.readline())
li = [int(i) for i in sys.stdin.readline().split()]
li2 = [int(j) for j in sys.stdin.readline().split()]
f = [0] * (t + 1)
g = [0] * (t + 1)
f[0] = g[0] = 0
for k in range(1, t + 1):
	f[k] = max(f[k - 1], g[k - 1] + li2[k - 1])
	g[k] = max(g[k - 1], f[k - 1] + li[k - 1])
print(max(f[t], g[t]))


n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
a = 0
b = 0
for i in range(n):
	a_ = b + aa[i]
	b_ = a + bb[i]
	a = max(a, a_)
	b = max(b, b_)
print(max(a, b))


t = int(input())
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
lst1 = [-1] * t
lst2 = [-1] * t
lst1[t - 1] = a[t - 1]
lst2[t - 1] = b[t - 1]
a_max = a[t - 1]
b_max = b[t - 1]
for i in range(t - 2, -1, -1):
	lst1[i] = a[i] + b_max
	lst2[i] = b[i] + a_max
	b_max = max(lst2[i], b_max)
	a_max = max(lst1[i], a_max)
print(max(lst1[0], lst2[0]))


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
(m1, m2) = (0, 0)
for i in range(n - 1, -1, -1):
	(x1, x2) = (l1[i] + m2, l2[i] + m1)
	if x1 > m1:
		m1 = x1
	if x2 > m2:
		m2 = x2
print(max(m1, m2))


n = int(input())
mat = []
for i in range(2):
	mat.append(list(map(int, input().split())))
dp = [[0] * n for i in range(2)]
dp[0][0] = mat[0][0]
dp[1][0] = mat[1][0]
if n == 1:
	print(max(dp[0][n - 1], dp[1][n - 1]))
else:
	dp[0][1] = dp[1][0] + mat[0][1]
	dp[1][1] = dp[0][0] + mat[1][1]
	if n == 2:
		print(max(dp[0][n - 1], dp[1][n - 1]))
	else:
		for i in range(2, n):
			for j in range(2):
				dp[j][i] = max(dp[1 - j][i - 1], dp[1 - j][i - 2]) + mat[j][i]
		print(max(dp[0][n - 1], dp[1][n - 1], dp[0][n - 2], dp[1][n - 2]))


I = lambda : map(int, input().split())
n = I()
temp = [0] * 3
for (x, y) in zip(I(), I()):
	c = max(temp[0], temp[1])
	a = max(temp[1] + x, temp[2] + x, x)
	b = max(temp[0] + y, temp[2] + y, y)
	temp = [a, b, c]
print(max(temp[0], temp[1]))


import math

def main():
	total = int(input())
	x = [int(number) for number in input().split()]
	y = [int(number) for number in input().split()]
	dp = [[0, 0, 0] for i in range(total)]
	dp[0][0] = 0
	dp[0][1] = x[0]
	dp[0][2] = y[0]
	for i in range(1, total, 1):
		dp[i][0] = max(dp[i - 1][0], dp[i - 1][1], dp[i - 1][2])
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + x[i]
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + y[i]
	print(max(dp[total - 1][0], dp[total - 1][1], dp[total - 1][2]))
main()


def is_safe(i, j, n):
	if i >= 0 and i < n and (j >= 0) and (j < n):
		return True
	return False
n = int(input())
mat = [list(map(int, input().split())), list(map(int, input().split()))]
dp = [[0] * (n + 1), [0] * (n + 1)]
for i in range(n):
	dp[0][i + 1] = max(dp[1][i] + mat[0][i], dp[0][i])
	dp[1][i + 1] = max(dp[0][i] + mat[1][i], dp[1][i])
print(max(dp[0][-1], dp[1][-1]))


n = int(input())
H0 = list(map(int, input().split()))
H1 = list(map(int, input().split()))
if n == 1:
	print(max(H0[0], H1[0]))
	exit()
dp = [0] * 3
dp[0] = H0[0]
dp[1] = H1[0]
dp[2] = 0
for i in range(1, n):
	nx = [0] * 3
	nx[2] = max(dp[0], dp[1])
	nx[0] = max(nx[0], dp[1] + H0[i], dp[2] + H0[i])
	nx[1] = max(nx[1], dp[0] + H1[i], dp[2] + H1[i])
	dp = nx
print(max(dp))


n = 0
row = list()
value = list()
n = int(input())
row.append(list(map(int, input().split())))
row.append(list(map(int, input().split())))
value.append([0] * n)
value.append([0] * n)
for i in range(n - 1, -1, -1):
	if i == n - 1:
		value[0][i] = row[0][i]
		value[1][i] = row[1][i]
	else:
		value[0][i] = row[0][i] + max(value[1][i + 1:i + 3])
		value[1][i] = row[1][i] + max(value[0][i + 1:i + 3])
print(max(value[0][0], value[1][0]))


N = int(input())
line2 = list(map(int, input().split()))
line3 = list(map(int, input().split()))
h = [line2, line3]
dp = [[0 for a in range(4)] for b in range(N + 2)]
for i in range(N):
	for row in range(1, 4):
		if row == 1:
			first = dp[i - 1][2] + h[0][i]
			second = dp[i - 1][3] + h[0][i]
			dp[i][row] = max(first, second, h[0][i])
		if row == 2:
			first = dp[i - 1][1] + h[1][i]
			second = dp[i - 1][3] + h[1][i]
			dp[i][row] = max(first, second, h[1][i])
		if row == 3:
			first = dp[i - 1][1]
			second = dp[i - 1][2]
			dp[i][row] = max(first, second)
print(max(dp[N - 1][1], dp[N - 1][2], dp[N - 1][3]))


def solve():
	n = int(input())
	h_1 = list(map(int, input().split()))
	h_2 = list(map(int, input().split()))
	(dp_1, dp_2, dp_3) = (0, 0, 0)
	for i in range(n):
		(t_dp_1, t_dp_2, t_dp_3) = (max(dp_2 + h_1[i], dp_3 + h_1[i]), max(dp_1 + h_2[i], dp_3 + h_2[i]), max(dp_1, dp_2))
		(dp_1, dp_2, dp_3) = (t_dp_1, t_dp_2, t_dp_3)
	print(max(dp_1, dp_2, dp_3))
solve()


t = 1
import math
while t > 0:
	t -= 1
	n = int(input())
	dp = [[0 for i in range(0, 2)] for i in range(0, n)]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for i in range(0, n):
		if i == 0:
			dp[i][0] = a[i]
			dp[i][1] = b[i]
		elif i == 1:
			dp[i][0] = a[i] + dp[i - 1][1]
			dp[i][1] = b[i] + dp[i - 1][0]
		else:
			dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 2][0], dp[i - 2][1])
			dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 2][1], dp[i - 2][0])
	print(max(dp[n - 1][0], dp[n - 1][1]))


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
n = int(cin())
h1 = list(map(int, cin().split()))
h2 = list(map(int, cin().split()))
(x, y, temp) = (0, 0, 0)
for i in range(n):
	x2 = max(y + h1[i], h1[i], temp + h1[i])
	y2 = max(x + h2[i], h2[i], temp + h2[i])
	temp = max(x, y)
	x = x2
	y = y2
cout(str(max(x, y)))


n = int(input())
l = [[int(j) for j in input().split()] for i in range(2)]
d1 = [0] * (n + 1)
d2 = [0] * (n + 1)
d1[0] = l[0][0]
d2[0] = l[1][0]
for i in range(1, n):
	d1[i] = max(d1[i - 1], d2[i - 1] + l[0][i])
	d2[i] = max(d2[i - 1], d1[i - 1] + l[1][i])
print(max(d1[n - 1], d2[n - 1]))


from sys import stdin, stdout
N = int(input())
arr1 = [int(x) for x in stdin.readline().split()]
arr2 = [int(x) for x in stdin.readline().split()]
up = [0] * N
down = [0] * N
up[0] = arr1[0]
down[0] = arr2[0]
for i in range(1, N):
	up[i] = max(up[i - 1], down[i - 1] + arr1[i])
	down[i] = max(down[i - 1], up[i - 1] + arr2[i])
print(max(up[-1], down[-1]))


n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
dp = [[0, 0] for j in range(n + 1)]
dp[0][0] = a1[0]
dp[0][1] = a2[0]
if n > 2:
	dp[1][0] = a1[1] + a2[0]
	dp[1][1] = a1[0] + a2[1]
for i in range(2, n):
	dp[i][0] = max(dp[i - 1][1] + a1[i], max(dp[i - 2][0], dp[i - 2][1]) + a1[i], dp[i - 1][0])
	dp[i][1] = max(dp[i - 1][0] + a2[i], max(dp[i - 2][1], dp[i - 2][0]) + a2[i], dp[i - 1][1])
print(max(dp[n - 1][1], dp[n - 1][0]))


def basketball(n, r1, r2):
	dpi1 = 0
	dpi2 = 0
	dpi3 = 0
	for i in range(n):
		dpi_1 = dpi1
		dpi_2 = dpi2
		dpi1 = max(dpi2 + r1[i], dpi3 + r1[i])
		dpi2 = max(dpi_1 + r2[i], dpi3 + r2[i])
		dpi3 = max(dpi_1, dpi_2)
	return max(dpi1, dpi2)
t = int(input())
a1 = list(map(int, input().split(' ')))
a2 = list(map(int, input().split(' ')))
print(basketball(t, a1, a2))


n = int(input())
r1 = list(map(int, input().split(' ')))
r2 = list(map(int, input().split(' ')))
given = [[0, 0] for x in range(n)]
array = [[0, 0, 0] for x in range(n)]
for i in range(n):
	given[i][0] = r1[i]
	given[i][1] = r2[i]
if n == 1:
	print(max(given[0]))
if n == 2:
	print(max(given[0][0] + given[1][1], given[0][1] + given[1][0]))
if n > 2:
	j = given[0].index(max(given[0]))
	array[0][0] = j
	array[0][1] = given[0][j]
	array[0][2] = given[0][(j + 1) % 2]
	temp = [given[0][1] + given[1][0], given[0][0] + given[1][1]]
	j = temp.index(max(temp))
	array[1][0] = j
	array[1][1] = temp[j]
	array[1][2] = temp[(j + 1) % 2]
	for i in range(2, n):
		k = 2 if array[i - 1][0] == 0 else 1
		l = 2 if array[i - 2][0] == 0 else 1
		temp0 = max(given[i][0] + array[i - 1][k], given[i][0] + array[i - 2][l])
		k = 2 if array[i - 1][0] == 1 else 1
		l = 2 if array[i - 2][0] == 1 else 1
		temp1 = max(given[i][1] + array[i - 1][k], given[i][1] + array[i - 2][l])
		temp2 = [temp0, temp1]
		j = temp2.index(max(temp2))
		array[i][0] = j
		array[i][1] = temp2[j]
		array[i][2] = temp2[(j + 1) % 2]
	print(array[-1][1])


def dp():
	arr = [[0 for j in range(3)] for i in range(n + 1)]
	for i in range(1, n + 1):
		for j in range(3):
			if j == 1:
				first = a[i - 1] + arr[i - 1][0]
				second = b[i - 1] + arr[i - 1][2]
				third = arr[i - 1][1]
				arr[i][j] = max(first, second, third)
			elif j == 0:
				first = b[i - 1] + arr[i - 1][2]
				second = arr[i - 1][1]
				arr[i][j] = max(first, second)
			else:
				first = a[i - 1] + arr[i - 1][0]
				second = arr[i - 1][1]
				arr[i][j] = max(first, second)
	return arr[n][1]
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(dp())


from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
n = int(input())
num1 = list(map(int, input().split()))
num0 = list(map(int, input().split()))
arr1 = (n + 1) * [0]
arr0 = (n + 1) * [0]

@bootstrap
def ans1(x):
	if x >= n:
		yield 0
	if arr1[x]:
		yield arr1[x]
	arr1[x] = num1[x] + max((yield ans0(x + 1)), (yield ans0(x + 2)))
	yield arr1[x]

@bootstrap
def ans0(x):
	if x >= n:
		yield 0
	if arr0[x]:
		yield arr0[x]
	arr0[x] = num0[x] + max((yield ans1(x + 1)), (yield ans1(x + 2)))
	yield arr0[x]
print(max(ans0(0), ans1(0)))


import sys
import math
from collections import defaultdict
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
n = int(input())
row1 = intInp()
row2 = intInp()
dp1 = row1[0]
dp2 = row2[0]
dp3 = 0
for i in range(1, n):
	tmp1 = max(dp2 + row1[i], dp3 + row1[i], row1[i])
	tmp2 = max(dp1 + row2[i], dp3 + row2[i], row2[i])
	tmp3 = max(dp1, dp2)
	dp1 = tmp1
	dp2 = tmp2
	dp3 = tmp3
print(max(dp1, dp2))


n = int(input())
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))
a1 = [s1[0]]
a2 = [s2[0]]
for i in range(0, n - 1):
	a1.append(max(a1[i], s1[i + 1] + a2[i]))
	a2.append(max(a2[i], s2[i + 1] + a1[i]))
print(max(a1[-1], a2[-1]))


from sys import stdin
input = stdin.readline
n = int(input())
ar1 = list(map(int, input().split()))
ar2 = list(map(int, input().split()))
dp = [[0, 0] for i in range(n)]
dp[0][0] = ar1[0]
dp[0][1] = ar2[0]
for i in range(1, n):
	dp[i][0] = max(dp[i - 1][0], dp[i - 1][1] + ar1[i])
	dp[i][1] = max(dp[i - 1][1], dp[i - 1][0] + ar2[i])
print(max(dp[n - 1]))


n = int(input())
first = list(map(int, input().split()))
second = list(map(int, input().split()))
dp_first = [0] * n
dp_second = [0] * n
dp_first[0] = first[0]
dp_second[0] = second[0]
for i in range(1, n):
	dp_first[i] = max(dp_first[i - 1], first[i] + dp_second[i - 1], first[i] + dp_second[i - 2] if i >= 2 else 0)
	dp_second[i] = max(dp_second[i - 1], second[i] + dp_first[i - 1], second[i] + dp_first[i - 2] if i >= 2 else 0)
print(max(dp_first[-1], dp_second[-1]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(max0, max1) = (0, 0)
for i in range(n):
	(max0, max1) = (max(max0, a[i] + max1), max(max1, b[i] + max0))
print(max(max0, max1))


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
t1 = h1[0]
t2 = h2[0]
for k in range(1, n):
	(t1, t2) = (max(t1, t2 + h1[k]), max(t2, t1 + h2[k]))
print(max(t1, t2))


def run():
	n = eval(input())
	up = list(map(int, input().split()))
	down = list(map(int, input().split()))
	values_up = [0] * n
	values_down = [0] * n
	values_up[-1] = up[-1]
	values_down[-1] = down[-1]
	max_up = up[-1]
	max_down = down[-1]
	for i in range(n - 2, -1, -1):
		values_up[i] = up[i] + max_down
		values_down[i] = down[i] + max_up
		if max_up < values_up[i]:
			max_up = values_up[i]
		if max_down < values_down[i]:
			max_down = values_down[i]
	print(max(max_up, max_down))
run()


n = int(input())
d = [int(i) for i in input().split()]
e = [int(i) for i in input().split()]
for j in range(1, n):
	d[j] = max(d[j] + e[j - 1], d[j - 1])
	e[j] = max(e[j] + d[j - 1], e[j - 1])
print(max(e[-1], d[-1]))


from sys import stdin
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
n = it()
a = mp()
b = mp()
dp = [[0 for i in range(3)] for j in range(n + 1)]
for i in range(1, n + 1):
	dp[i][0] = max(dp[i - 1])
	dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + a[i - 1]
	dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + b[i - 1]
print(max(dp[n]))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(1):
	n = l()[0]
	h1 = l()
	h2 = l()
	dp = [h1[:] + [0], h2[:] + [0]]
	for i in range(-3, -n - 2, -1):
		dp[1][i] += max(dp[0][i + 1], dp[0][i + 2])
		dp[0][i] += max(dp[1][i + 1], dp[1][i + 2])
	print(max(dp[0][0], dp[1][0]))


from sys import stdin, stdout, exit
n = int(stdin.readline())
top = list(map(int, stdin.readline().split()))
bot = list(map(int, stdin.readline().split()))
top_dp = [0] * (n + 1)
bot_dp = [0] * (n + 1)
for i in range(n):
	top_dp[i + 1] = max(top_dp[i], bot_dp[i] + top[i])
	bot_dp[i + 1] = max(bot_dp[i], top_dp[i] + bot[i])
ans = max(top_dp[n], bot_dp[n])
stdout.write(str(ans) + '\n')


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if n == 1:
	exit(print(max(a[0], b[0])))
dp = [[0] * n for i in range(2)]
dp[0][0] = a[0]
dp[1][0] = b[0]
dp[0][1] = b[0] + a[1]
dp[1][1] = a[0] + b[1]
for i in range(2, n):
	dp[0][i] = max(dp[1][i - 1], dp[1][i - 2]) + a[i]
	dp[1][i] = max(dp[0][i - 1], dp[0][i - 2]) + b[i]
print(max(dp[0][n - 1], dp[1][n - 1]))


def main():
	n = int(input())
	a = []
	a.append(list(map(int, input().split())))
	a.append(list(map(int, input().split())))
	for i in range(1, n):
		a[i % 2][i] = max(a[(i + 1) % 2][i - 1] + a[i % 2][i], a[i % 2][i - 1])
		a[(i + 1) % 2][i] = max(a[i % 2][i - 1] + a[(i + 1) % 2][i], a[(i + 1) % 2][i - 1])
	print(max(a[0][n - 1], a[1][n - 1]))
	return
main()


n = int(input())
a = []
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
ans = [[0, 0] for _ in range(n + 2)]
for i in range(n):
	z = max(ans[i - 2])
	y = ans[i - 1][1] + a[0][i]
	y = max(y, z + a[0][i])
	ans[i][0] = y
	y = ans[i - 1][0] + a[1][i]
	y = max(y, z + a[1][i])
	ans[i][1] = y
m = 0
for i in ans:
	m = max(m, max(i))
print(m)


for t in range(1):
	n = int(input())
	row1 = list(map(int, input().split()))
	row2 = list(map(int, input().split()))
	dp1 = [0] * n
	dp1[0] = row1[0]
	dp2 = [0] * n
	dp2[0] = row2[0]
	for i in range(1, n):
		dp1[i] = max(dp2[i - 1] + row1[i], dp1[i - 1])
		dp2[i] = max(dp1[i - 1] + row2[i], dp2[i - 1])
	print(max(dp2[-1], dp1[-1]))


input()
a = []
for i in range(2):
	a.append([int(i) for i in input().split()])
dp = [[0 for i in range(len(a[0]) + 4)] for _ in range(2)]
if len(a[0]) == 1:
	print(max(a[0][0], a[1][0]))
	exit(0)
for i in range(len(a[0])):
	dp[0][i] = max(dp[1][i - 1], dp[1][i - 2]) + a[0][i]
	dp[1][i] = max(dp[0][i - 1], dp[0][i - 2]) + a[1][i]
print(max(dp[0][len(a[0]) - 1], dp[1][len(a[0]) - 1]))


n = int(input())
(a, b) = ([int(x) for x in input().split()], [int(x) for x in input().split()])
if n == 1:
	print(max(a[0], b[0]))
else:
	(ps, qs) = ([0] * n, [0] * n)
	(ps[-1], ps[-2], qs[-1], qs[-2]) = (a[-1], a[-2] + b[-1], b[-1], b[-2] + a[-1])
	for j in range(n - 3, -1, -1):
		ps[j] = a[j] + max(qs[j + 1], qs[j + 2])
		qs[j] = b[j] + max(ps[j + 1], ps[j + 2])
	print(max(ps[0], qs[0]))


inc1 = [0]
inc2 = [0]
a = int(input())
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))
inc1.append(s1[0])
inc2.append(s2[0])
for i in range(1, len(s1)):
	r = max(inc1[-1] + s2[i], max(inc1[-2], inc2[-2]) + s2[i])
	l = max(inc2[-1] + s1[i], max(inc1[-2], inc2[-2]) + s1[i])
	inc2.append(r)
	inc1.append(l)
print(max(max(inc1), max(inc2)))


n = int(input())
list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
ans = [[], []]
for i in range(n):
	ans[0].append(0)
	ans[1].append(0)
ans[0][0] = list1[0]
ans[1][0] = list2[0]
for i in range(1, n):
	ans[0][i] = max(ans[0][i - 1], list1[i] + ans[1][i - 1])
	ans[1][i] = max(ans[1][i - 1], list2[i] + ans[0][i - 1])
print(max(ans[0][-1], ans[1][-1]))


import sys
n = int(sys.stdin.readline().strip())
h1 = list(map(int, sys.stdin.readline().strip().split()))
h2 = list(map(int, sys.stdin.readline().strip().split()))
m1 = 0
n1 = h1[0]
m2 = 0
n2 = h2[0]
for i in range(1, n):
	(m1, n1, m2, n2) = (n1, h1[i] + max([m2, n2]), n2, h2[i] + max([m1, n1]))
print(max([n1, n2]))


t = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(d0, d1) = (0, 0)
(m, n) = (0, 0)
for x in range(t):
	m = max(d0, d1 + a[x])
	n = max(d1, d0 + b[x])
	(d0, d1) = (m, n)
print(max(d0, d1))


n = int(input())
arr_0 = [int(i) for i in filter(None, input().split(' '))]
arr_1 = [int(i) for i in filter(None, input().split(' '))]
arr = [arr_0, arr_1]
end = [[0] * n, [0] * n]
if n == 1:
	print(max([arr[0][0], arr[1][0]]))
elif n == 2:
	print(max(arr[0][0] + arr[1][1], arr[1][0] + arr[0][1]))
else:
	for i in range(2 * n):
		num = i % 2
		el_num = 1 - num
		ind = i // 2
		end[num][ind] = max(end[el_num][ind - 1], end[el_num][ind - 2]) + arr[num][ind]
	print(max(end[0][-1], end[1][-1]))


n = int(input())
dp = [[0 for i in range(3)] for j in range(n)]
first = tuple(map(int, input().split()))
second = tuple(map(int, input().split()))
dp[0][0] = first[0]
dp[0][1] = second[0]
for i in range(1, n):
	dp[i][0] = max(dp[i - 1][1] + first[i], dp[i - 1][2] + first[i], first[i])
	dp[i][1] = max(dp[i - 1][0] + second[i], dp[i - 1][2] + second[i], second[i])
	dp[i][2] = max(dp[i - 1][0], dp[i - 1][1])
print(max(dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans1 = 0
ans2 = 0
for i in range(n):
	(ans1, ans2) = (max(ans1, ans2 + a[i]), max(ans2, ans1 + b[i]))
print(max(ans1, ans2))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dp = [0, 0]
for i in range(n):
	v1 = max(dp[0], dp[1] + a[i])
	v2 = max(dp[1], dp[0] + b[i])
	(dp[0], dp[1]) = (v1, v2)
print(max(dp[0], dp[1]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = list(zip(a, b))
dp = [[None, None] for i in range(n)]
dp[n - 1][0] = a[n - 1][0]
dp[n - 1][1] = a[n - 1][1]
for i in range(n - 2, -1, -1):
	if a[i][0] + dp[i + 1][1] > dp[i + 1][0]:
		dp[i][0] = a[i][0] + dp[i + 1][1]
	else:
		dp[i][0] = dp[i + 1][0]
	if a[i][1] + dp[i + 1][0] > dp[i + 1][1]:
		dp[i][1] = a[i][1] + dp[i + 1][0]
	else:
		dp[i][1] = dp[i + 1][1]
print(max(dp[0][0], dp[0][1]))


from math import *
n = int(input())
m1 = list(map(int, input().split()))
m2 = list(map(int, input().split()))
dp = [[0] * 2 for i in range(n)]
if n == 1:
	print(max(m1[0], m2[0]))
	return
if n == 2:
	print(max(m1[0] + m2[1], m2[0] + m1[1]))
	return
dp[0][0] = m1[0]
dp[0][1] = m2[0]
dp[1][0] = m2[0] + m1[1]
dp[1][1] = m2[1] + m1[0]
for i in range(2, n):
	dp[i][0] = max(dp[i - 1][1] + m1[i], dp[i - 2][1] + m1[i])
	dp[i][1] = max(dp[i - 1][0] + m2[i], dp[i - 2][0] + m2[i])
print(max(dp[n - 1]))


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
try:
	(sys.stdin, sys.stdout) = (open('in.txt', 'r'), open('out.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
n = ii1()
ar = iia()
arr = iia()
arr = list(zip(ar, arr))
d = [0, 0]
for i in range(n):
	next = [max(d[0], d[1] + arr[i][0]), max(d[1], d[0] + arr[i][1])]
	d = next
print(max(d))


def basekt(p1, p2):
	him = [0] * len(p1)
	us = [0] * len(p2)
	him[0] = p1[0]
	us[0] = p2[0]
	for i in range(1, len(p1)):
		him[i] = max(him[i - 1], p1[i] + us[i - 1])
		us[i] = max(us[i - 1], p2[i] + him[i - 1])
	return max(max(him), max(us))
a = input()
lst1 = list(map(int, input().strip().split()))
lst2 = list(map(int, input().strip().split()))
print(basekt(lst1, lst2))


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
l = [h1, h2]
dp = [[0 for i in range(3)] for j in range(n + 1)]
for i in range(1, n + 1):
	dp[i][0] = max(dp[i - 1])
	dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + l[0][i - 1]
	dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + l[1][i - 1]
print(max(dp[n]))


import os
import sys
import math
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def dijkstra(start, distance, path, n):
	visited = [False for _ in range(n)]
	distance[start] = 0
	for i in range(n):
		v = -1
		for j in range(n):
			if not visited[v] and (v == -1 or distance[j] < distance[v]):
				v = j
		if distance[v] == math.inf:
			break
		visited[v] = True
		for edge in adj[v]:
			destination = edge[0]
			weight = edge[1]
			if distance[v] + weight < distance[destination]:
				distance[destination] = distance[v] + weight
				path[destination] = v

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def ncr(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def npr(n, r):
	return math.factorial(n) // math.factorial(n - r)

def seive(n):
	primes = [True] * (n + 1)
	ans = []
	for i in range(2, n):
		if not primes[i]:
			continue
		j = 2 * i
		while j <= n:
			primes[j] = False
			j += i
	for p in range(2, n + 1):
		if primes[p]:
			ans += [p]
	return ans

def factors(n):
	factors = []
	x = 1
	while x * x <= n:
		if n % x == 0:
			if n // x == x:
				factors.append(x)
			else:
				factors.append(x)
				factors.append(n // x)
		x += 1
	return factors

def main():
	try:
		n = inp()
		a = []
		b = inlt()
		c = inlt()
		for i in range(n):
			a.append([b[i], c[i]])
		dp = [0, 0]
		for i in range(n):
			(dp[0], dp[1]) = (max(dp[0], dp[1] + a[i][0]), max(dp[1], dp[0] + a[i][1]))
		print(max(dp))
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
v = [[int(i) for i in input().split()], [int(i) for i in input().split()]]
dp = [[0] * (n + 1), [0] * (n + 1)]
for i in range(1, n + 1):
	dp[0][i] = max(dp[0][i - 1], dp[1][i - 1] + v[0][i - 1])
	dp[1][i] = max(dp[1][i - 1], dp[0][i - 1] + v[1][i - 1])
print(max(dp[0][n], dp[1][n]))


n = int(input())
mat = []
mat.append(list(map(int, input().split())))
mat.append(list(map(int, input().split())))
dp = [[0 for j in range(n)] for i in range(3)]
dp[1][0] = mat[0][0]
dp[2][0] = mat[1][0]
for i in range(1, n):
	dp[0][i] = max(dp[0][i - 1], dp[1][i - 1], dp[2][i - 1])
	dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + mat[0][i]
	dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + mat[1][i]
res = max(max(dp[0]), max(dp[1]), max(dp[2]))
print(res)


n = int(input())
row_1 = list(map(int, input().split()))
row_2 = list(map(int, input().split()))
dp_flg1 = [0 for _ in range(n + 2)]
dp_flg2 = [0 for _ in range(n + 2)]
for i in range(n):
	dp_flg2[i + 2] = max(dp_flg1[i + 1] + row_2[i], dp_flg1[i] + row_2[i])
	dp_flg1[i + 2] = max(dp_flg2[i + 1] + row_1[i], dp_flg2[i] + row_1[i])
print(max(dp_flg1[n + 1], dp_flg2[n + 1]))


import sys
n = int(sys.stdin.readline())
line0 = list(map(int, sys.stdin.readline().strip().split()))
line1 = list(map(int, sys.stdin.readline().strip().split()))
dp = [[0] * 2 for _ in range(n)]
dp[0][0] = line0[0]
dp[0][1] = line1[0]
if n == 1:
	print(max(line0[0], line1[0]))
else:
	dp[1][0] = dp[0][1] + line0[1]
	dp[1][1] = dp[0][0] + line1[1]
	for i in range(2, n):
		dp[i][0] = max(dp[i - 2][1], dp[i - 1][1]) + line0[i]
		dp[i][1] = max(dp[i - 2][0], dp[i - 1][0]) + line1[i]
	print(max(dp[-1][0], dp[-1][1]))


n = int(input())
a = []
for _ in range(2):
	a.append([int(i) for i in input().split()])
dp = [[0 for _ in range(n)] for _ in range(2)]
dp[0][0] = a[0][0]
dp[1][0] = a[1][0]
for j in range(1, n):
	for i in range(2):
		x = 0
		if j - 1 >= 0:
			x = max(x, dp[1 - i][j - 1])
		if j - 2 >= 0:
			x = max(x, dp[i][j - 2])
			x = max(x, dp[1 - i][j - 2])
		dp[i][j] = a[i][j] + x
print(max(max(dp[0]), max(dp[1])))


n = int(input())
matrix = []
arr = [int(i) for i in input().split()]
arr1 = [int(i) for i in input().split()]
matrix.append(arr)
matrix.append(arr1)
dp = [[0 for i in range(n)] for j in range(2)]
dp[0][0] = matrix[0][0]
dp[1][0] = matrix[1][0]
for i in range(1, n):
	if i >= 2:
		dp[0][i] = max(matrix[0][i] + dp[1][i - 1], matrix[0][i] + dp[1][i - 2])
		dp[1][i] = max(matrix[1][i] + dp[0][i - 1], matrix[1][i] + dp[0][i - 2])
	else:
		dp[0][i] = matrix[0][i] + dp[1][i - 1]
		dp[1][i] = matrix[1][i] + dp[0][i - 1]
print(max(dp[0][-1], dp[1][-1]))


n = int(input())
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))
dp = []
for i in range(2):
	dp.append([0] + [0 for i in range(n)])
for i in range(1, n + 1):
	dp[0][i] = max(dp[0][i - 1], dp[1][i - 1] + s1[i - 1])
	dp[1][i] = max(dp[1][i - 1], dp[0][i - 1] + s2[i - 1])
print(max(dp[1][n], dp[0][n]))


x = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dp1 = [0 for n in range(x)]
dp2 = [0 for n in range(x)]
dp3 = [0 for n in range(x)]
dp1[0] = a[0]
dp2[0] = b[0]
for n in range(1, x):
	dp1[n] = max(dp2[n - 1] + a[n], dp3[n - 1] + a[n])
	dp2[n] = max(dp1[n - 1] + b[n], dp3[n - 1] + b[n])
	dp3[n] = max(dp1[n - 1], dp2[n - 1])
print(max(dp1[-1], dp2[-1], dp3[-1]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dp = [a[0], b[0], 0]
for i in range(n - 1):
	dp_1 = max(dp[1], dp[2]) + a[i + 1]
	dp_2 = max(dp[0], dp[2]) + b[i + 1]
	dp_3 = max(dp[0], dp[1])
	dp = [dp_1, dp_2, dp_3]
print(max(dp))


n = int(input())
h1 = [int(s) for s in input().split()]
h2 = [int(s) for s in input().split()]
max1 = 0
max2 = 0
for i in range(n):
	max1t = max(max1, max2 + h1[i])
	max2t = max(max2, max1 + h2[i])
	(max1, max2) = (max1t, max2t)
print(max(max1, max2))


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
t = h1[-1]
b = h2[-1]
for i in range(n - 2, -1, -1):
	ct = h1[i] + b
	cb = h2[i] + t
	t = max(ct, t)
	b = max(cb, b)
print(max(t, b))


n = int(input())
h = list(map(int, input().split()))
s = list(map(int, input().split()))
if len(h) == 1:
	print(max(h[0], s[0]))
else:
	max_h = [h[0], s[0] + h[1]]
	max_s = [s[0], h[0] + s[1]]
	for i in range(2, len(h)):
		max_h.append(max(max_s[i - 1] + h[i], max_s[i - 2] + h[i]))
		max_s.append(max(max_h[i - 1] + s[i], max_h[i - 2] + s[i]))
	print(max(max_h[-1], max_s[-1]))


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = 0
y = 0
for i in range(n):
	(x, y) = (max(x, y + a[i]), max(y, x + b[i]))
print(max(x, y))


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from itertools import combinations, permutations
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())

def solve():
	ii()
	x = y = 0
	arr = rr()
	brr = rr()
	for (i, j) in zip(arr, brr):
		(x, y) = (max(y + i, x), max(x + j, y))
	print(max(x, y))
for _ in range(1):
	solve()


def calc_max_height_team(n, t1, t2):
	mht = [[0 for i in range(n)] for j in range(3)]
	if n == 1:
		return max(t1[0], t2[0])
	mht[0][0] = t1[0]
	mht[1][0] = t2[0]
	mht[2][0] = 0
	for i in range(1, n):
		mht[0][i] = max(mht[1][i - 1] + t1[i], mht[2][i - 1] + t1[i])
		mht[1][i] = max(mht[0][i - 1] + t2[i], mht[2][i - 1] + t2[i])
		mht[2][i] = max(mht[0][i - 1], mht[1][i - 1])
	return max(mht[0][n - 1], mht[1][n - 1])

def solve():
	n = int(input())
	f_t = list(map(lambda x: int(x), input().split()))
	s_t = list(map(lambda x: int(x), input().split()))
	print(int(calc_max_height_team(n, f_t, s_t)))
solve()


q = int(input())
w = list(map(int, input().split()))
e = list(map(int, input().split()))
mw = [0] * q
me = [0] * q
mw[0] = w[0]
me[0] = e[0]
for i in range(q - 2):
	if mw[i] + e[i + 1] > me[i + 1]:
		me[i + 1] = mw[i] + e[i + 1]
	if mw[i] + e[i + 2] > me[i + 2]:
		me[i + 2] = mw[i] + e[i + 2]
	if me[i] + w[i + 1] > mw[i + 1]:
		mw[i + 1] = me[i] + w[i + 1]
	if me[i] + w[i + 2] > mw[i + 2]:
		mw[i + 2] = me[i] + w[i + 2]
i = q - 2
if i >= 0:
	if mw[i] + e[i + 1] > me[i + 1]:
		me[i + 1] = mw[i] + e[i + 1]
	if me[i] + w[i + 1] > mw[i + 1]:
		mw[i + 1] = me[i] + w[i + 1]
print(max(me[-1], mw[-1]))


def solve():
	n = int(input())
	t1 = list(map(int, input().split()))
	t2 = list(map(int, input().split()))
	t1_score = [0 for i in range(n)]
	t2_score = [0 for i in range(n)]
	n -= 1
	t1_score[n] = t1[n]
	t2_score[n] = t2[n]
	n -= 1
	while n >= 0:
		t1_score[n] = max(t2_score[n + 1] + t1[n], t1_score[n + 1])
		t2_score[n] = max(t1_score[n + 1] + t2[n], t2_score[n + 1])
		n -= 1
	print(max(t1_score[0], t2_score[0]))
solve()


a = int(input())
b = list(map(int, input().split()))
c = list(map(int, input().split()))
dp = [[] for x in range(a)]
for x in range(a):
	dp[x].append(b[x])
	dp[x].append(c[x])
for x in range(a - 1):
	dp[x + 1][0] = max(dp[x][0], dp[x][1] + dp[x + 1][0])
	dp[x + 1][1] = max(dp[x][1], dp[x][0] + dp[x + 1][1])
print(max(dp[a - 1][0], dp[a - 1][1]))


n = int(input())
r1 = [int(i) for i in input().split()]
r2 = [int(i) for i in input().split()]
dp1 = [0] * n
dp2 = [0] * n
dp1[0] = r1[0]
dp2[0] = r2[0]
for i in range(n - 1):
	if i < n - 2:
		dp1[i + 2] = max(dp1[i + 2], dp2[i] + r1[i + 2])
		dp2[i + 2] = max(dp2[i + 2], dp1[i] + r2[i + 2])
	dp1[i + 1] = max(dp1[i + 1], dp2[i] + r1[i + 1])
	dp2[i + 1] = max(dp2[i + 1], dp1[i] + r2[i + 1])
print(max(dp1[-1], dp2[-1]))


n = int(input())
first = [int(i) for i in input().split()]
second = [int(i) for i in input().split()]
dp = [[0, 0] for i in range(n)]
dp[0][0] = first[0]
dp[0][1] = second[0]
for i in range(0, n - 1):
	dp[i + 1][0] = max(dp[i][0], dp[i][1] + first[i + 1])
	dp[i + 1][1] = max(dp[i][1], dp[i][0] + second[i + 1])
print(max(dp[n - 1][0], dp[n - 1][1]))


n = int(input())
h1 = [int(i) for i in input().split()]
h2 = [int(i) for i in input().split()]
ans1 = 0
ans2 = 0
for i in range(n):
	(ans1, ans2) = (max(ans1, ans2 + h1[i]), max(ans2, ans1 + h2[i]))
print(max(ans1, ans2))


from sys import stdin
input = stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(dp1, dp2, dp3) = ([0] * n, [0] * n, [0] * n)
(dp1[0], dp2[0], dp3[0]) = (a[0], b[0], 0)
for i in range(1, n):
	dp1[i] = max(dp2[i - 1] + a[i], dp3[i - 1], dp1[i - 1])
	dp2[i] = max(dp1[i - 1] + b[i], dp3[i - 1], dp2[i - 1])
	dp3[i] = max(dp2[i - 1], dp3[i - 1], dp1[i - 1])
print(max(dp1[n - 1], dp2[n - 1], dp3[n - 1]))


n = int(input())
a = [None] * 2
a[0] = list(map(int, input().split()))
a[1] = list(map(int, input().split()))
dp = [[0, 0] for _ in range(n)]
for i in range(n):
	for j in range(2):
		dp[i][j] = a[j][i]
		if i > 0:
			dp[i][j] = max(dp[i][j], dp[i - 1][1 - j] + a[j][i])
		if i > 1:
			dp[i][j] = max(dp[i][j], dp[i - 2][1 - j] + a[j][i])
print(max(dp[n - 1][0], dp[n - 1][1]))


CHOSE_A = 0
CHOSE_B = 1
CHOSE_NEITHER = 2
n = int(input())
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
memo = []
for i in range(n):
	memo.append([-1, -1, -1])
memo[n - 1][CHOSE_B] = a[n - 1]
memo[n - 1][CHOSE_A] = b[n - 1]
memo[n - 1][CHOSE_NEITHER] = max(a[n - 1], b[n - 1])
for i in range(n - 2, -1, -1):
	memo[i][CHOSE_A] = max(b[i] + memo[i + 1][CHOSE_B], memo[i + 1][CHOSE_NEITHER])
	memo[i][CHOSE_B] = max(a[i] + memo[i + 1][CHOSE_A], memo[i + 1][CHOSE_NEITHER])
	memo[i][CHOSE_NEITHER] = max(a[i] + memo[i + 1][CHOSE_A], b[i] + memo[i + 1][CHOSE_B], memo[i + 1][CHOSE_NEITHER])
print(memo[0][CHOSE_NEITHER])


n = int(input())
rows = []
rows.append(list(map(int, input().split())))
rows.append(list(map(int, input().split())))
best = [0, 0]
nextBest = [0, 0]
for k in range(n):
	nextBest[0] = max(best[1] + rows[0][k], best[0])
	nextBest[1] = max(best[0] + rows[1][k], best[1])
	best[0] = nextBest[0]
	best[1] = nextBest[1]
print(max(best))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
i = 1
while i < len(a):
	if b[i] + a[i - 1] >= b[i - 1]:
		b[i] = b[i] + a[i - 1]
	else:
		b[i] = b[i - 1]
	if a[i] + b[i - 1] >= a[i - 1]:
		a[i] = a[i] + b[i - 1]
	else:
		a[i] = a[i - 1]
	i = i + 1
print(max(a[-1], b[-1]))


def selectTeam(H1, H2):
	i = 0
	n = len(H1)
	amax = H1[i]
	bmax = H2[i]
	max1 = H1[i]
	max2 = H2[i]
	i = 1
	while i < n:
		amax = H1[i] + max2
		bmax = H2[i] + max1
		max1 = max(max1, amax)
		max2 = max(max2, bmax)
		i = i + 1
	return max(amax, bmax)
n = int(input())
H1 = [int(ele) for ele in input().split()]
H2 = [int(ele) for ele in input().split()]
print(selectTeam(H1, H2))


n = int(input())
li1 = list(map(int, input().split()))
li2 = list(map(int, input().split()))
max1 = li1[0]
max2 = li2[0]
for i in range(1, n):
	max1e = max(max2 + li1[i], max1)
	max2e = max(max1 + li2[i], max2)
	max1 = max1e
	max2 = max2e
print(max(max1, max2))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
r1 = list(map(int, input().rstrip().split(' ')))
r2 = list(map(int, input().rstrip().split(' ')))
dp = [[0, 0, 0] for i in range(n + 1)]
for i in range(n):
	dp[i + 1][0] = max(dp[i])
	dp[i + 1][1] = max(dp[i][0], dp[i][2]) + r1[i]
	dp[i + 1][2] = max(dp[i][0], dp[i][1]) + r2[i]
print(max(dp[-1]))


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
dp1 = [a[0]] + [0] * (n - 1)
dp2 = [b[0]] + [0] * (n - 1)
for i in range(1, n):
	dp1[i] = max(dp2[i - 1] + a[i], dp1[i - 1])
	dp2[i] = max(dp1[i - 1] + b[i], dp2[i - 1])
print(max(dp1[n - 1], dp2[n - 1]))


n = int(input())
h = [[] for _ in range(2)]
h[0] = list(map(int, input().split()))
h[1] = list(map(int, input().split()))
h[0].insert(0, 0)
h[1].insert(0, 0)
dp = [[0 for __ in range(2)] for _ in range(n + 1)]
best_edge = [-1] * (n + 1)
dp[0][0] = h[0][0]
dp[0][1] = h[1][0]
dp[1][0] = dp[0][0] + h[0][1]
dp[1][1] = dp[0][1] + h[1][1]
for i in range(2, n + 1):
	dp[i][0] = max(dp[i - 1][1] + h[0][i], dp[i - 2][1] + h[0][i])
	dp[i][1] = max(dp[i - 1][0] + h[1][i], dp[i - 2][0] + h[1][i])
print(max(dp[n]))


from sys import stdin

def main():
	n = int(input())
	hh = []
	hh.append(list(map(int, input().split())))
	hh.append(list(map(int, input().split())))
	sum1 = 0
	sum1l = 0
	sum2 = 0
	sum2l = 0
	for i in range(n):
		sum1 += hh[i % 2][i]
		sum2 += hh[1 - i % 2][i]
		if sum1l > sum2:
			sum2 = sum1l
		if sum2l > sum1:
			sum1 = sum2l
		sum1l = sum1
		sum2l = sum2
	print(max(sum1, sum2, sum1l, sum2l))
main()


import sys
input = sys.stdin.readline
n = int(input())
h0 = list(map(int, input().split()))
h1 = list(map(int, input().split()))
(dp0, dp1) = ([0] * (n + 5), [0] * (n + 5))
(dp0[0], dp1[0]) = (h0[0], h1[0])
for i in range(1, n):
	dp0[i] = max(dp1[i - 1], dp1[i - 2], dp0[i - 2]) + h0[i]
	dp1[i] = max(dp0[i - 1], dp1[i - 2], dp0[i - 2]) + h1[i]
print(max(max(dp0), max(dp1)))


n = int(input())
ranges = {}
ranges[1] = list(map(int, input().split()))
ranges[2] = list(map(int, input().split()))
f1 = [0]
f2 = [0]
f3 = [0]
for i in range(1, n + 1):
	f3.append(max(f1[i - 1], f2[i - 1]))
	f2.append(max(f1[i - 1] + ranges[2][i - 1], f3[i - 1] + ranges[2][i - 1]))
	f1.append(max(f2[i - 1] + ranges[1][i - 1], f3[i - 1] + ranges[1][i - 1]))
print(max(f1[n], f2[n]))


n = int(input())
h_1_x = [int(i) for i in input().split()]
h_2_x = [int(i) for i in input().split()]
x = 0
y = 0
for i in range(n):
	aux = x
	x = max(x, y + h_1_x[i])
	y = max(aux + h_2_x[i], y)
print(max(x, y))


n = int(input())
line_1 = list(map(int, input().split(' ')))
line_2 = list(map(int, input().split(' ')))
dp_1 = [0] * n
dp_1[0] = line_1[0]
dp_2 = [0] * n
dp_2[0] = line_2[0]
dp_3 = [0] * n
for i in range(1, n):
	dp_1[i] = max(dp_2[i - 1] + line_1[i], dp_3[i - 1] + line_1[i], line_1[i])
	dp_2[i] = max(dp_1[i - 1] + line_2[i], dp_3[i - 1] + line_2[i], line_2[i])
	dp_3[i] = max(dp_1[i - 1], dp_2[i - 1])
print(max(dp_1[n - 1], dp_2[n - 1]))


n = int(input())
a = [0, 0]
(*a[0],) = map(int, input().split())
(*a[1],) = map(int, input().split())
dp = [[0, 0] for i in range(n + 1)]
for i in range(n):
	for j in [0, 1]:
		dp[i][j] = max(dp[i - 1][j], dp[i - 1][j ^ 1] + a[j][i])
print(max(dp[n - 1]))


def solve(n, queue1, queue2):
	ans1 = [0] * n
	ans2 = [0] * n
	ans1[n - 1] = queue1[n - 1]
	ans2[n - 1] = queue2[n - 1]
	for index in range(n - 2, -1, -1):
		temp = queue1[index] + ans2[index + 1]
		ans1[index] = max(temp, ans1[index + 1])
		temp = queue2[index] + ans1[index + 1]
		ans2[index] = max(temp, ans2[index + 1])
	return max(ans1[0], ans2[0])
n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
print(solve(n, l1, l2))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
memo = {}

def f(a, b, i, is_last_el_a, memo):
	if (i, is_last_el_a) in memo:
		return memo[i, is_last_el_a]
	if i == 0:
		if is_last_el_a:
			memo[i, is_last_el_a] = a[0]
		else:
			memo[i, is_last_el_a] = b[0]
		return memo[i, is_last_el_a]
	if i == 1:
		if is_last_el_a:
			memo[i, is_last_el_a] = a[1] + b[0]
		else:
			memo[i, is_last_el_a] = b[1] + a[0]
		return memo[i, is_last_el_a]
	cur_value = b[i]
	if is_last_el_a:
		cur_value = a[i]
	memo[i, is_last_el_a] = max(f(a, b, i - 1, not is_last_el_a, memo) + cur_value, f(a, b, i - 2, not is_last_el_a, memo) + cur_value)
	return memo[i, is_last_el_a]
max_height = -1
for i in range(n):
	max_height = max(f(a, b, i, True, memo), f(a, b, i, False, memo))
print(max_height)


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import *
n = ii()
a = il()
b = il()
dp = [0] * n
for i in range(0, n):
	dp[i] = [0, 0]
dp[0][0] = a[0]
dp[0][1] = b[0]
for i in range(1, n):
	dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][0])
	dp[i][1] = max(dp[i - 1][0] + b[i], dp[i - 1][1])
ans = max(dp[n - 1][0], dp[n - 1][1])
print(ans)


try:
	while True:
		n = int(input())
		a = [[0]] * 2
		a[0] = list(map(int, input().split()))
		a[0].insert(0, 0)
		a[1] = list(map(int, input().split()))
		a[1].insert(0, 0)
		suma = maxa = a[0][1]
		sumb = maxb = a[1][1]
		for i in range(2, n + 1):
			suma = maxb + a[0][i]
			sumb = maxa + a[1][i]
			maxa = max(maxa, suma)
			maxb = max(maxb, sumb)
		print(max(maxa, maxb))
except EOFError:
	pass


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
x = [0] * (n + 1)
y = [0] * (n + 1)
x[1] = h1[0]
y[1] = h2[0]
for i in range(1, n):
	x[i + 1] = max(y[i], y[i - 1]) + h1[i]
	y[i + 1] = max(x[i], x[i - 1]) + h2[i]
ans = max(x[n], y[n])
print(ans)


n = int(input())
l = [list(map(int, input().split())), list(map(int, input().split()))]
m = [0, 0]
for i in range(n - 1, -1, -1):
	mm = [0, 0]
	for j in range(2):
		l[j][i] += m[j ^ 1]
		mm[j] = max(m[j], l[j][i])
	m = mm
print(max(m))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l1 = [0] * n
l2 = [0] * n
l3 = [0] * n
l1[0] = a[0]
l2[0] = b[0]
for i in range(1, n):
	l1[i] = max(l2[i - 1], l3[i - 1]) + a[i]
	l2[i] = max(l1[i - 1], l3[i - 1]) + b[i]
	l3[i] = max(l1[i - 1], l2[i - 1], l3[i - 1])
print(max(l1[-1], l2[-1], l3[-1]))


n = int(input())
row_1 = list(map(int, input().split()))
row_2 = list(map(int, input().split()))
dp = [[0] * n, [0] * n]
dp[0][0] = row_1[0]
dp[1][0] = row_2[0]
for i in range(1, n):
	dp[0][i] = max(row_1[i] + dp[1][i - 1], dp[0][i - 1])
	dp[1][i] = max(row_2[i] + dp[0][i - 1], dp[1][i - 1])
print(max(dp[0][n - 1], dp[1][n - 1]))


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = [a[n - 1], b[n - 1]]
bans = [0, 0]
for i in range(n - 2, -1, -1):
	bans[0] = max(a[i] + ans[1], ans[0])
	bans[1] = max(b[i] + ans[0], ans[1])
	ans[0] = bans[0]
	ans[1] = bans[1]
	bans[0] = 0
	bans[1] = 0
print(max(ans))


from sys import stdin

def solution2():
	input = stdin.readline
	n = int(input())
	arr1 = [int(x) for x in input().split()]
	arr2 = [int(x) for x in input().split()]
	a = a1 = arr1[0]
	b = b1 = arr2[0]
	c = c1 = 0
	for i in range(1, n):
		a1 = max(b + arr1[i], c + arr1[i])
		b1 = max(a + arr2[i], c + arr2[i])
		c1 = max(a, b)
		a = a1
		b = b1
		c = c1
	print(max(a1, b1, c1))
solution2()


import sys
num = int(input())
row1 = [int(i) for i in input().split()]
row2 = [int(i) for i in input().split()]
if num == 1:
	print(max(row1[0], row2[0]))
	sys.exit()
row1.reverse()
row2.reverse()
dp = [[row1[0], row2[0]], [row2[0] + row1[1], row1[0] + row2[1]]]
for i in range(2, num):
	top = max(dp[-1][1] + row1[i], dp[-2][1] + row1[i], dp[-1][0])
	bot = max(dp[-1][0] + row2[i], dp[-2][0] + row2[i], dp[-1][1])
	dp.append([top, bot])
print(max(dp[-1]))


import sys
sys.setrecursionlimit(1000000)
l = int(sys.stdin.readline().strip())
first = list(map(int, sys.stdin.readline().split()))
second = list(map(int, sys.stdin.readline().split()))
maxHi = [-1] * l * 2

def maxH(i, even):
	if i >= l:
		return 0
	if maxHi[i * 2 + (0 if even else 1)] > -1:
		return maxHi[i * 2 + (0 if even else 1)]
	ret = max(maxH(i + 1, not even) + (first[i] if even else second[i]), maxH(i + 1, even))
	maxHi[i * 2 + (0 if even else 1)] = ret
	return ret
for i in range(l - 1, -1, -1):
	maxH(i, True)
	maxH(i, False)
print(max(maxH(0, True), maxH(0, False)))


import sys
input = sys.stdin.readline
n = int(input())
H0 = list(map(int, input().split()))
H1 = list(map(int, input().split()))
DP0 = [0] * (n + 5)
DP1 = [0] * (n + 5)
DP0[0] = H0[0]
DP1[0] = H1[0]
for i in range(1, n):
	DP0[i] = max(DP1[i - 1], DP1[i - 2], DP0[i - 2]) + H0[i]
	DP1[i] = max(DP0[i - 1], DP0[i - 2], DP1[i - 2]) + H1[i]
print(max(max(DP0), max(DP1)))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = [[0 for i in range(2)] for i in range(n + 1)]
l[1] = [a[0], b[0]]
for i in range(2, n + 1):
	l[i][0] = max(l[i - 1][1] + a[i - 1], l[i - 2][1] + a[i - 1])
	l[i][1] = max(l[i - 1][0] + b[i - 1], l[i - 2][0] + b[i - 1])
print(max(l[-1]))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		b = LI()
		dp = [0] * 3
		for (c, d) in zip(a, b):
			np = [0] * 3
			np[0] = max(dp)
			np[1] = max(dp[0], dp[2]) + c
			np[2] = max(dp[0], dp[1]) + d
			dp = np
		rr.append(max(dp))
	return JA(rr, '\n')
print(main())


n = int(input())
a = [] * 2
for i in range(2):
	tmp = list(map(int, input().split()))
	a.append(tmp)
if n == 1:
	print(max(a[0][0], a[1][0]))
else:
	f = [[0] * n for i in range(2)]
	f[0][0] = a[0][0]
	f[1][0] = a[1][0]
	f[0][1] = f[1][0] + a[0][1]
	f[1][1] = f[0][0] + a[1][1]
	ans = max(f[0][1], f[1][1])
	for i in range(2, n):
		f[0][i] = max(f[0][i - 2], max(f[1][i - 1], f[1][i - 2])) + a[0][i]
		f[1][i] = max(f[1][i - 2], max(f[0][i - 1], f[0][i - 2])) + a[1][i]
		ans = max(ans, max(f[0][i], f[1][i]))
	print(ans)


def run(n, a, b):
	F = [[None] * (n + 1) for i in range(2)]
	F[0][n - 1] = a[n - 1]
	F[1][n - 1] = b[n - 1]
	F[0][n] = 0
	F[1][n] = 0
	for i in range(n - 2, -1, -1):
		maxx = max(F[0][i + 2], F[1][i + 2])
		F[0][i] = max(F[1][i + 1], maxx) + a[i]
		F[1][i] = max(F[0][i + 1], maxx) + b[i]
	return max(F[0][0], F[1][0])
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
F = run(n, a, b)
print(F)


n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
ans1 = ans2 = 0
for i in range(n):
	(a1, a2) = (ans1, ans2)
	ans1 = max(a1, a2 + h1[i])
	ans2 = max(a2, a1 + h2[i])
print(max(ans1, ans2))


def line(conv=int, fl=0):
	inp = input().split()
	if len(inp) == 1 and (not fl):
		return conv(inp[0])
	return map(conv, inp)
n = line()
h = [list(line(fl=1)), list(line(fl=1))]
a = zip(*h)
m = [0, 0]
for (a0, a1) in a:
	nm = [0, 0]
	nm[0] = max(m[0], m[1] + a0)
	nm[1] = max(m[1], m[0] + a1)
	m = nm
print(max(m))


from sys import stdin
n = int(stdin.readline())
heights = []
heights.append([int(x) for x in stdin.readline().split()])
heights.append([int(x) for x in stdin.readline().split()])
maxes = [[0] * n for i in range(2)]
maxes[0][n - 1] = heights[0][n - 1]
maxes[1][n - 1] = heights[1][n - 1]
old_top_max = maxes[0][n - 1]
top_max = maxes[0][n - 1]
bot_max = maxes[1][n - 1]
for x in range(n - 2, -1, -1):
	for y in range(2):
		if y == 0:
			maxes[y][x] = max(heights[y][x] + bot_max, top_max)
			top_max = maxes[y][x]
		if y == 1:
			maxes[y][x] = max(heights[y][x] + old_top_max, bot_max)
			bot_max = maxes[y][x]
			old_top_max = top_max
print(max(maxes[0][0], maxes[1][0]))


dp = [[], []]

def solve(T, N):
	dp[0].append(T[0][0])
	dp[1].append(T[1][0])
	for i in range(1, N):
		dp[0].append(T[0][i] + max(dp[1][i - 1], dp[1][i - 2] if i >= 2 else 0))
		dp[1].append(T[1][i] + max(dp[0][i - 1], dp[0][i - 2] if i >= 2 else 0))
	print(max(dp[0][-1], dp[1][-1]))
n = int(input())
team = []
line = list(map(int, input().split()))
team.append(line)
line = list(map(int, input().split()))
team.append(line)
solve(team, n)


from sys import stdin

def solution():
	input = stdin.readline
	n = int(input())
	arr1 = [int(x) for x in input().split()]
	arr2 = [int(x) for x in input().split()]
	dp1 = [0] * n
	dp2 = [0] * n
	dp3 = [0] * n
	dp1[0] = arr1[0]
	dp2[0] = arr2[0]
	for i in range(1, n):
		dp1[i] = max(dp2[i - 1] + arr1[i], dp3[i - 1] + arr1[i])
		dp2[i] = max(dp1[i - 1] + arr2[i], dp3[i - 1] + arr2[i])
		dp3[i] = max(dp1[i - 1], dp2[i - 1])
	print(max(dp3[-1], dp2[-1], dp1[-1]))
solution()


n = int(input())
h = [[0] * n for _ in range(2)]
for i in range(2):
	h[i] = list(map(int, input().split()))
(max0, max1) = (0, 0)
for i in range(n):
	(max0, max1) = (max(max0, h[0][n - i - 1] + max1), max(max1, h[1][n - i - 1] + max0))
print(max(max0, max1))


n = int(input())
h1 = [int(i) for i in input().split()]
h2 = [int(i) for i in input().split()]
ph1 = [0] * n
ph2 = [0] * n
ph1[0] = h1[0]
ph2[0] = h2[0]
for i in range(1, n):
	ph1[i] = max(ph1[i - 1], ph2[i - 1] + h1[i])
	ph2[i] = max(ph2[i - 1], ph1[i - 1] + h2[i])
print(max(ph1[n - 1], ph2[n - 1]))


import sys
import math
input = sys.stdin.readline
n = int(input())
h1 = list(map(int, input().split()))
h2 = list(map(int, input().split()))
if n == 1:
	print(max(h1[0], h2[0]))
else:
	dp1 = [h1[0], h2[0] + h1[1]]
	dp2 = [h2[0], h2[1] + h1[0]]
	for i in range(2, n):
		dp1.append(max(dp2[i - 1] + h1[i], h1[i] + dp2[i - 2]))
		dp2.append(max(dp1[i - 1] + h2[i], h2[i] + dp1[i - 2]))
	print(max(max(dp1), max(dp2)))


n = input()
row1 = [x for x in map(int, input().split())]
row2 = [x for x in map(int, input().split())]

def largest_height(row1, row2):
	largest_r1 = row1[0]
	largest_r2 = row2[0]
	for ind in range(1, len(row1)):
		new_largest_r1 = max(largest_r1, largest_r2 + row1[ind])
		new_largest_r2 = max(largest_r2, largest_r1 + row2[ind])
		(largest_r1, largest_r2) = (new_largest_r1, new_largest_r2)
	return max(largest_r1, largest_r2)
print(largest_height(row1, row2))


n = int(input())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
if n == 1:
	print(max(arr1[0], arr2[0]))
else:
	dp1 = [arr1[0], arr2[0] + arr1[1]]
	dp2 = [arr2[0], arr2[1] + arr1[0]]
	for i in range(2, n):
		dp1.append(max(dp2[i - 1] + arr1[i], arr1[i] + dp2[i - 2]))
		dp2.append(max(dp1[i - 1] + arr2[i], arr2[i] + dp1[i - 2]))
	print(max(dp1[n - 1], dp2[n - 1]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
u = v = w = x = 0
for i in range(len(a)):
	w = max(u, v + a[i])
	x = max(v, u + b[i])
	(u, v) = (w, x)
print(max(u, v))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if n == 1:
	print(max(a[0], b[0]))
else:
	dpa = [0] * n
	dpb = [0] * n
	dpa[0] = a[0]
	dpb[0] = b[0]
	dpa[1] = dpb[0] + a[1]
	dpb[1] = dpa[0] + b[1]
	i = 2
	while i < n:
		dpa[i] = max(dpb[i - 1], dpb[i - 2]) + a[i]
		dpb[i] = max(dpa[i - 1], dpa[i - 2]) + b[i]
		i += 1
	m1 = max(dpb)
	m2 = max(dpa)
	print(max(m1, m2))


n = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
DP = [[0] * n for _ in range(2)]
DP[0][0] = A[0]
DP[1][0] = B[0]
for i in range(1, n):
	DP[0][i] = max(A[i] + DP[1][i - 1], DP[0][i - 1])
	DP[1][i] = max(B[i] + DP[0][i - 1], DP[1][i - 1])
print(max(DP[0][n - 1], DP[1][n - 1]))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(mxa, mxb) = (0, 0)
for (x, y) in zip(a, b):
	(mxa, mxb) = (max(mxa, mxb + x), max(mxb, mxa + y))
print(max(mxa, mxb))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(a0, a1, b0, b1) = (0, a[0], 0, b[0])
for k in range(1, n):
	a2 = a[k] + max(b0, b1)
	b2 = b[k] + max(a0, a1)
	(a0, a1, b0, b1) = (a1, a2, b1, b2)
print(max(a1, b1))


n = int(input())
arr1 = list(map(int, input().strip().split()))
arr2 = list(map(int, input().strip().split()))
dp = [0, 0, 0]
for i in range(n):
	t1 = max(dp[1], dp[2]) + arr1[i]
	t2 = max(dp[0], dp[2]) + arr2[i]
	t3 = max(dp[1], dp[2], dp[0])
	dp = [t1, t2, t3]
print(max(dp))


def optimize(A, B, n):
	F = [[None for x in range(n + 1)] for y in range(3)]
	for i in range(1, 3):
		F[i][0] = 0
	F[1][1] = A[1]
	F[2][1] = B[1]
	for i in range(2, n + 1):
		F[1][i] = max(F[2][i - 1] + A[i], F[2][i - 2] + A[i])
		F[2][i] = max(F[1][i - 1] + B[i], F[1][i - 2] + B[i])
	return max(F[1][n], F[2][n])
n = int(input())
A = [None]
B = [None]
for x in input().split():
	B.append(int(x))
for x in input().split():
	A.append(int(x))
print(optimize(A, B, n))


def safeaccess(arr, i):
	if i >= len(arr) or i < 0:
		return 0
	return arr[i]
n = int(input())
array1 = [int(x) for x in input().split(' ')]
array2 = [int(x) for x in input().split(' ')]
dpa1 = [0] * n
dpa2 = [0] * n
maxnum = 0
for i in range(n):
	dpa1[i] = max(safeaccess(dpa2, i - 1) + array1[i], safeaccess(dpa2, i - 2) + array1[i])
	dpa2[i] = max(safeaccess(dpa1, i - 1) + array2[i], safeaccess(dpa1, i - 2) + array2[i])
	maxnum = max(maxnum, dpa1[i], dpa2[i])
print(maxnum)


n = int(input())
arr1 = [int(p) for p in input().split()]
arr2 = [int(p) for p in input().split()]
ans1 = [0] * n
ans2 = [0] * n
if n == 1:
	print(max(arr1[0], arr2[0]))
	exit()
ans1[0] = arr1[0]
ans2[0] = arr2[0]
ans1[1] = arr1[1] + ans2[0]
ans2[1] = arr2[1] + ans1[0]
for i in range(2, n):
	ans1[i] = max(ans2[i - 1] + arr1[i], ans2[i - 2] + arr1[i])
	ans2[i] = max(ans1[i - 1] + arr2[i], ans1[i - 2] + arr2[i])
print(max(ans1[-1], ans2[-1]))


from sys import stdin, stdout
read = lambda : map(int, stdin.readline().split())
I = lambda : stdin.readline()
n = int(I())
arr = [tuple(read()) for i in range(2)]
dp = [[0 for i in range(3)] for i in range(n + 1)]
for i in range(n - 1, -1, -1):
	dp[i][0] = max(dp[i + 1][2], arr[1][i] + dp[i + 1][1])
	dp[i][1] = max(dp[i + 1][2], arr[0][i] + dp[i + 1][0])
	dp[i][2] = max(dp[i + 1][2], arr[0][i] + dp[i + 1][0], arr[1][i] + dp[i + 1][1])
print(dp[0][2])
quit()
s = input()
n = len(s)
temp = [int(i) for i in s]
ans = ['' for i in range(9)]
for i in temp:
	for j in range(9):
		ans[j] += '01'[i > j]
ans = [i for i in map(int, ans) if i]
print(len(ans))
print(*ans)
quit()
from sys import stdin, stdout
read = lambda : map(int, stdin.readline().split())
I = lambda : stdin.readline()
n = int(I())
arr = tuple(read())
memo = {}
poss = [[0], [0, 1], [0, 2], [0, 1, 2]]
dp = [[10 ** 6 for i in range(3)] for i in range(n + 1)]
dp[n] = [0, 0, 0]
for i in range(n - 1, -1, -1):
	for last in range(3):
		for p in poss[arr[i]]:
			dp[i][last] = min(dp[i][last], (1 if last & p or p == 0 else 0) + dp[i + 1][p])
print(dp[0][0])


n = int(input())
one = [int(x) for x in input().split()]
two = [int(x) for x in input().split()]
dp = {(0, 1, 1): one[0], (0, 1, 0): two[0], (0, 2, 1): two[0], (0, 2, 0): one[0]}
for i in range(1, n):
	dp[i, 1, 1] = max(dp[i - 1, 2, 1], dp[i - 1, 1, 0]) + one[i]
	dp[i, 1, 0] = max(dp[i - 1, 2, 1], dp[i - 1, 1, 1], dp[i - 1, 1, 0], dp[i - 1, 2, 0])
	dp[i, 2, 1] = max(dp[i - 1, 1, 1], dp[i - 1, 2, 0]) + two[i]
	dp[i, 2, 0] = max(dp[i - 1, 1, 1], dp[i - 1, 2, 1], dp[i - 1, 1, 0], dp[i - 1, 2, 0])
print(max(dp[n - 1, 1, 0], dp[n - 1, 1, 1], dp[n - 1, 2, 0], dp[n - 1, 2, 1]))


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve(n, m):
	if n >= m:
		return n - m
	if m % 2:
		return 1 + solve(n, m + 1)
	return 1 + solve(n, m // 2)

def main():
	n = get_int()
	a = get_list()
	b = get_list()
	(x, y) = (0, 0)
	for i in range(n):
		(x, y) = (max(x, y + a[i]), max(y, x + b[i]))
	print(max(x, y))
TestCases = False
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


from math import gcd

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

def output_list(v):
	print(' '.join((str(x) for x in v)))

def main():
	n = int(input())
	h1 = input_ints()
	h2 = input_ints()
	dp1 = [0] * (n + 1)
	dp2 = [0] * (n + 1)
	ma1 = 0
	ma2 = 0
	for i in range(n):
		dp1[i + 1] = ma2 + h1[i]
		dp2[i + 1] = ma1 + h2[i]
		ma1 = max(ma1, dp1[i + 1])
		ma2 = max(ma2, dp2[i + 1])
	print(max(ma1, ma2))
main()


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
r1 = [[l1[0], l1[0]]] + [[0, 1] for _ in range(n - 1)]
r2 = [[l2[0], l2[0]]] + [[0, 1] for _ in range(n - 1)]
(result1, result2) = (0, 0)
for i in range(n):
	a = result1
	result1 = max(result1, result2 + l1[i])
	result2 = max(result2, a + l2[i])
print(max(result1, result2))


n = int(input())
h = [list(map(int, input().split())), list(map(int, input().split()))]
if n == 1:
	if h[0][0] > h[1][0]:
		print(h[0][0])
	else:
		print(h[1][0])
else:
	emp = []
	for i in range(n + 1):
		emp.append([0, 0])
	emp[1][0] = h[0][0]
	emp[1][1] = h[1][0]
	for i in range(1, n):
		emp[i + 1][0] = max(emp[i - 1][1], emp[i][1]) + h[0][i]
		emp[i + 1][1] = max(emp[i - 1][0], emp[i][0]) + h[1][i]
	print(max(emp[n]))


n = int(input())
left = list(map(int, input().split()))
right = list(map(int, input().split()))
sequences = [(0, 0)]
for i in range(n):
	new = []
	m = {0: 0, 1: 0, 2: 0}
	for s in sequences:
		new.append((0, s[1]))
		m[0] = max(m[0], s[1])
		if not s[0] == 1:
			new.append((1, s[1] + left[i]))
			m[1] = max(m[1], s[1] + left[i])
		if not s[0] == 2:
			new.append((2, s[1] + right[i]))
			m[2] = max(m[2], s[1] + right[i])
	sequences = [(0, m[0]), (1, m[1]), (2, m[2])]
m = 0
for s in sequences:
	m = max(m, s[1])
print(m)


n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
if n == 1:
	print(max(a1[0], a2[0]))
else:
	f = [a1[0], a2[0]]
	s = [a1[1] + f[1], a2[1] + f[0]]
	dp = [f, s]
	for i in range(2, n):
		an = [max(dp[i - 1][1] + a1[i], dp[i - 2][1] + a1[i]), max(dp[i - 1][0] + a2[i], dp[i - 2][0] + a2[i])]
		dp.append(an)
	print(max(dp[-1][0], dp[-1][1]))


n = int(input())
h = []
h.append(list(map(int, input().split())))
h.append(list(map(int, input().split())))
dp = [[0 for i in range(n + 1)], [0 for j in range(n + 1)]]
for i in range(1, n + 1):
	dp[0][i] = max(dp[0][i - 1], dp[1][i - 1] + h[0][i - 1])
	dp[1][i] = max(dp[1][i - 1], dp[0][i - 1] + h[1][i - 1])
print(max(dp[0][n], dp[1][n]))


import sys
input = sys.stdin.readline
n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
dp = [0] * n
dp[-1] = [l1[-1], l2[-1]]
if n >= 2:
	dp[-2] = [l1[-2] + l2[-1], l2[-2] + l1[-1]]
	for i in range(-3, -n - 1, -1):
		ind = i
		k = max(dp[ind + 1][1] + l1[ind], dp[ind + 2][1] + l1[ind])
		kk = max(dp[ind + 1][0] + l2[ind], dp[ind + 2][0] + l2[ind])
		dp[ind] = [k, kk]
print(max(dp[0]))


import sys
n = int(sys.stdin.readline())
h1 = list(map(int, sys.stdin.readline().split()))
h2 = list(map(int, sys.stdin.readline().split()))
best_last_up = [0] * (n + 2)
best_last_down = [0] * (n + 2)
for i in range(n):
	best_last_up[i + 1] = max(best_last_up[i + 1], best_last_down[i] + h1[i])
	best_last_up[i + 2] = max(best_last_up[i + 2], best_last_down[i] + h1[i])
	best_last_down[i + 1] = max(best_last_down[i + 1], best_last_up[i] + h2[i])
	best_last_down[i + 2] = max(best_last_down[i + 2], best_last_up[i] + h2[i])
print(max(best_last_up[n], best_last_down[n]))


def solution(x, y):
	d0 = [0] * len(x)
	dx = [x[0]] * len(x)
	dy = [y[0]] * len(x)
	for k in range(1, len(x)):
		d0[k] = max(dx[k - 1], dy[k - 1])
		dx[k] = max(d0[k - 1], dy[k - 1]) + x[k]
		dy[k] = max(d0[k - 1], dx[k - 1]) + y[k]
	return max(d0[-1], dx[-1], dy[-1])
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
print(solution(x, y))


n = int(input())
dp = []
for i in range(2):
	dp.append(list(map(int, input().split())))
dp[0].insert(0, 0)
dp[0].insert(0, 0)
dp[1].insert(0, 0)
dp[1].insert(0, 0)
for i in range(2, n + 2):
	for k in range(2):
		if k == 0:
			dp[k][i] = max(dp[1][i - 1], dp[1][i - 2]) + dp[k][i]
		else:
			dp[k][i] = max(dp[0][i - 1], dp[0][i - 2]) + dp[k][i]
print(max(dp[0][-1], dp[1][-1]))