Alice and Bob are playing a game on a matrix, consisting of $2$ rows and $m$ columns. The cell in the $i$-th row in the $j$-th column contains $a_{i, j}$ coins in it.

Initially, both Alice and Bob are standing in a cell $(1, 1)$. They are going to perform a sequence of moves to reach a cell $(2, m)$.

The possible moves are:

Move right — from some cell $(x, y)$ to $(x, y + 1)$;

Move down — from some cell $(x, y)$ to $(x + 1, y)$.

First, Alice makes all her moves until she reaches $(2, m)$. She collects the coins in all cells she visit (including the starting cell).

When Alice finishes, Bob starts his journey. He also performs the moves to reach $(2, m)$ and collects the coins in all cells that he visited, but Alice didn't.

The score of the game is the total number of coins Bob collects.

Alice wants to minimize the score. Bob wants to maximize the score. What will the score of the game be if both players play optimally?


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of testcases.

Then the descriptions of $t$ testcases follow.

The first line of the testcase contains a single integer $m$ ($1 \le m \le 10^5$) — the number of columns of the matrix.

The $i$-th of the next $2$ lines contain $m$ integers $a_{i,1}, a_{i,2}, \dots, a_{i,m}$ ($1 \le a_{i,j} \le 10^4$) — the number of coins in the cell in the $i$-th row in the $j$-th column of the matrix.

The sum of $m$ over all testcases doesn't exceed $10^5$.


-----Output-----

For each testcase print a single integer — the score of the game if both players play optimally.


-----Examples-----

Input
3
3
1 3 7
3 5 1
3
1 3 9
3 5 1
1
4
7
Output
7
8
0


-----Note-----

The paths for the testcases are shown on the following pictures. Alice's path is depicted in red and Bob's path is depicted in blue.

Difficulty: EASY

Solutions:
inf = 100000000000000000

def linput():
	return list(map(int, input().split()))
for _ in range(int(input())):
	n = int(input())
	l1 = linput()
	l2 = linput()
	suff1 = [l1[-1]]
	for i in range(n - 2, -1, -1):
		suff1.append(l1[i] + suff1[-1])
	suff1 = suff1[::-1]
	pre2 = [l2[0]]
	for i in range(1, n):
		pre2.append(l2[i] + pre2[-1])
	mini = inf
	for i in range(n):
		val1 = suff1[i] - l1[i]
		val2 = pre2[i] - l2[i]
		mini = min(mini, max(val1, val2))
	print(mini)


import sys

def input():
	return sys.stdin.readline().rstrip()
DXY = [(0, -1), (1, 0), (0, 1), (-1, 0)]

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = [list(map(int, input().split())) for i in range(2)]
		a[0].reverse()
		b = [[0] * (n + 1) for i in range(2)]
		for i in range(1, n + 1):
			b[0][i] = b[0][i - 1] + a[0][i - 1]
			b[1][i] = b[1][i - 1] + a[1][i - 1]
		ans = min((max(b[0][i], b[1][n - 1 - i]) for i in range(n)))
		print(ans)
	return 0
main()


import sys
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	z = []
	z.append(a)
	z.append(b)
	sum1 = sum(a)
	ans = sys.maxsize
	sum2 = 0
	for i in range(n):
		sum1 -= z[0][i]
		ans = min(ans, max(sum1, sum2))
		sum2 += z[1][i]
	print(ans)


import sys, os
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
from itertools import combinations
for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	s = 0
	if n == 1:
		print(0)
		continue
	x = sum(A[1:])
	mx = x
	y = 0
	for i in range(1, n):
		x -= A[i]
		y += B[i - 1]
		mx = min(mx, max(x, y))
	print(mx)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	t = int(input())
	for _ in range(t):
		m = int(input())
		a1 = [int(ai1) for ai1 in input().split()]
		a2 = [int(ai2) for ai2 in input().split()]
		pref_a1 = [0] * (m + 1)
		pref_a2 = [0] * (m + 1)
		for i in range(m):
			pref_a1[i + 1] = pref_a1[i] + a1[i]
			pref_a2[i + 1] = pref_a2[i] + a2[i]
		sol = float('inf')
		for i in range(m):
			sol = min(sol, max(pref_a1[-1] - pref_a1[i + 1], pref_a2[i]))
		print(sol)
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


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')
from collections import *
from collections import deque
from operator import itemgetter, attrgetter
from decimal import *
import bisect
import math
import heapq as hq
MOD = 10 ** 9 + 7

def is_prime(n):
	if n == 2 or n == 3:
		return True
	if n < 2 or n % 2 == 0:
		return False
	if n < 9:
		return True
	if n % 3 == 0:
		return False
	r = int(n ** 0.5)
	f = 5
	while f <= r:
		if n % f == 0:
			return False
		if n % (f + 2) == 0:
			return False
		f += 6
	return True

def pow(a, b, m):
	ans = 1
	while b:
		if b & 1:
			ans = ans * a % m
		b //= 2
		a = a * a % m
	return ans

def ispalindrome(s):
	if s[:] == s[::-1]:
		return 1
	return 0
dp = []
limit = []
v = []

def dpdfs(u, t=-1):
	dp[0][u] = 0
	dp[1][u] = 0
	for i in v[u]:
		if i == t:
			continue
		if dp[1][i] == -1:
			dpdfs(i, u)
		dp[0][u] += max(abs(limit[0][u] - limit[1][i]) + dp[1][i], abs(limit[0][u] - limit[0][i]) + dp[0][i])
		dp[1][u] += max(abs(limit[1][u] - limit[1][i]) + dp[1][i], abs(limit[1][u] - limit[0][i]) + dp[0][i])
vis = []
f = 0

def dfs(i):
	vis[i] = 1
	act[i] = 1
	for j in v[i]:
		if act[j]:
			f = 1
			return -1
		if vis[j] == 0:
			if dfs(j) == -1:
				return -1
	act[i] = 0
	ans.append(i)
	return 0
from queue import PriorityQueue

def z_algorithm(s):
	res = [0] * len(s)
	res[0] = len(s)
	(i, j) = (1, 0)
	while i < len(s):
		while i + j < len(s) and s[j] == s[i + j]:
			j += 1
		res[i] = j
		if j == 0:
			i += 1
			continue
		k = 1
		while i + k < len(s) and k + res[k] < j:
			res[i + k] = res[k]
			k += 1
		(i, j) = (i + k, j - k)
	return res

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

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

def gcdExtended(a, b):
	if a == 0:
		return (b, 0, 1)
	(gcd, x1, y1) = gcdExtended(b % a, a)
	x = y1 - b // a * x1
	y = x1
	return (gcd, x, y)
import re
for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(2):
		l.append(list(map(int, input().split())))
	ans = math.inf
	l[0][0] = 0
	l[1][n - 1] = 0
	l[1].append(0)
	for i in range(1, n):
		l[0][i] += l[0][i - 1]
		l[1][i] += l[1][i - 1]
	for i in range(n):
		ans = min(ans, max(l[0][n - 1] - l[0][i], l[1][i - 1]))
	print(ans)


for i in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	brr = [int(i) for i in input().split()]
	if n == 1:
		print(0)
	elif n == 2:
		print(min(arr[1], brr[0]))
	else:
		for i in range(1, n):
			arr[i] += arr[i - 1]
			brr[i] += brr[i - 1]
		for i in range(n):
			if i == 0:
				m = arr[-1] - arr[0]
			else:
				m = min(m, max(arr[-1] - arr[i], brr[i - 1]))
		print(m)


for _ in range(int(input())):
	m = int(input())
	s = [list(map(int, input().split())) for i in range(2)]
	for i in range(1, m):
		s[0][m - i - 1] += s[0][m - i]
		s[1][i] += s[1][i - 1]
	if m == 1:
		print(0)
	else:
		answer = s[0][1]
		for i in range(2, m):
			tmp = max(s[0][i], s[1][i - 2])
			answer = min(tmp, answer)
		print(min(answer, s[1][-2]))


for case in range(int(input())):
	m = int(input())
	a = [[int(i) for i in input().split()] for i in range(2)]
	s1 = [0 for i in range(m)]
	for i in range(m - 1, -1, -1):
		s1[i] = (s1[i + 1] if i + 1 < m else 0) + (a[0][i + 1] if i + 1 < m else 0)
	s2 = [0 for i in range(m)]
	for i in range(m):
		s2[i] = (s2[i - 1] if i - 1 >= 0 else 0) + (a[1][i - 1] if i - 1 >= 0 else 0)
	ans = float('inf')
	for i in range(m):
		ans = min(ans, max(s1[i], s2[i]))
	print(ans)


t = int(input())
for _ in range(t):
	m = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a_pred = [a[0]]
	b_pred = [b[0]]
	for i in range(1, m):
		a_pred.append(a_pred[-1] + a[i])
		b_pred.append(b_pred[-1] + b[i])
	ans = a_pred[-1] - a_pred[0]
	for i in range(1, m):
		ans = min(max(a_pred[-1] - a_pred[i], b_pred[i] - b[i]), ans)
	print(ans)


def coinRows(grid, m):
	grid[0][0] = 0
	grid[1][m - 1] = 0
	prefixSum = [[grid[i][j] for j in range(m)] for i in range(2)]
	suffixSum = [[grid[i][j] for j in range(m)] for i in range(2)]
	for i in range(1, m):
		prefixSum[0][i] += prefixSum[0][i - 1]
		prefixSum[1][i] += prefixSum[1][i - 1]
	for i in range(m - 2, -1, -1):
		suffixSum[0][i] += suffixSum[0][i + 1]
		suffixSum[1][i] += suffixSum[1][i + 1]
	score = float('inf')
	for i in range(m):
		t = score
		if 1 <= i < m - 1:
			first = suffixSum[0][i + 1]
			second = prefixSum[1][i - 1]
			t = max(first, second)
		elif i == 0 and i + 1 < m:
			t = suffixSum[0][i + 1]
		elif i == m - 1 and i > 0:
			t = prefixSum[1][i - 1]
		score = min(score, t)
	return score if score != float('inf') else 0
t = int(input())
for case in range(t):
	m = int(input())
	grid = []
	for i in range(2):
		grid.append(list(map(int, input().split())))
	print(coinRows(grid, m))


t = int(input())
for i in range(t):
	m = int(input())
	h = list(map(int, input().split()))
	l = list(map(int, input().split()))
	maxi = 10 ** 10
	hsum = sum(h)
	lsum = 0
	for j in range(m):
		hsum -= h[j]
		if j > 0:
			lsum += l[j - 1]
		maxi = min(maxi, max(hsum, lsum))
	print(maxi)


import sys
import itertools
cin = int(sys.stdin.readline().strip())
for testcase in range(cin):
	cin1 = int(sys.stdin.readline().strip())
	cin2 = list(map(int, sys.stdin.readline().strip().split()))
	cin3 = list(map(int, sys.stdin.readline().strip().split()))
	a1 = [0] + list(itertools.accumulate(cin2))
	a2 = [0] + list(itertools.accumulate(cin3))
	t1 = a1[-1]
	t2 = a2[-1]
	a = float('inf')
	for i in range(len(a1)):
		a = min(a, max(t1 - a1[i], a2[i - 1]))
	print(a)


for _ in range(int(input())):
	m = int(input())
	row1 = list(map(int, input().split()))
	row2 = list(map(int, input().split()))
	score = 10 ** 9
	sufix = sum(row1)
	prefix = 0
	for i in range(m):
		sufix -= row1[i]
		score = min(score, max(prefix, sufix))
		prefix += row2[i]
	print(score)


T = int(input())
for _ in range(T):
	n = int(input())
	a = []
	a.append(list(map(int, input().split())))
	a.append(list(map(int, input().split())))
	(s0, s1) = (sum(a[0]), sum(a[1]))
	res = [s0 - a[0][0]]
	(up, down) = (res[0], 0)
	for i in range(1, n):
		up -= a[0][i]
		down += a[1][i - 1]
		res.append(max(up, down))
	print(min(res))


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	a = [0, sum(A[1:n])]
	ans = max(a)
	for i in range(1, n):
		a = [a[0] + B[i - 1], a[1] - A[i]]
		ans = min(ans, max(a))
	print(ans)


import math
t = int(input())
for _ in range(t):
	m = int(input())
	r1 = [int(i) for i in input().split()]
	r2 = [int(i) for i in input().split()]
	sum1 = sum(r1[1:])
	ans = sum1
	sum2 = 0
	for i in range(1, len(r1)):
		sum1 -= r1[i]
		sum2 += r2[i - 1]
		ans = min(ans, max(sum1, sum2))
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = a.copy()
	l.reverse()
	s = 0
	for i in range(n - 1):
		s = s + b[i]
	r = 0
	ans = 0
	m = 0
	m = max(s, r)
	ans = m
	for i in range(n - 1):
		r = r + l[i]
		s = s - b[n - i - 2]
		m = max(s, r)
		if m < ans:
			ans = m
	print(ans)


t = int(input())
while t:
	t -= 1
	m = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	p1 = [0]
	p2 = [0]
	for i in range(m):
		p1.append(p1[-1] + a[i])
		p2.append(p2[-1] + b[i])
	ans = float('inf')
	for i in range(m):
		ans = min(ans, max(p1[-1] - p1[i + 1], p2[i]))
	print(ans)


def answer():
	N = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	Sa = sum(a[1:])
	Sb = 0
	ans = Sa
	for i in range(N - 1):
		Sa -= a[i + 1]
		Sb += b[i]
		ans = min(max(Sa, Sb), ans)
	print(ans)
t = int(input())
for _ in range(t):
	answer()


t = int(input())
for _ in range(t):
	m = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	z1 = sum(l1)
	z2 = sum(l2)
	t = [z1 - l1[0], z2 - l2[-1]]
	a = z1 - l1[0]
	b = 0
	for i in range(1, m - 1):
		a -= l1[i]
		b += l2[i - 1]
		t.append(max(a, b))
	print(min(t))


for _ in range(int(input())):
	(m, str_1, str_2) = (int(input()), list(map(int, input().split())), list(map(int, input().split())))
	(a, b) = (sum(str_1) - str_1[0], 0)
	ans = a
	for i in range(1, m):
		a -= str_1[i]
		b += str_2[i - 1]
		ans = min(max(a, b), ans)
	print(ans)


import sys
import math

def inpu():
	return sys.stdin.readline()
T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	done = False
	sa = sum(a) - a[0]
	ans = sa
	sb = 0
	for i in range(1, n):
		sa -= a[i]
		sb += b[i - 1]
		ans = min(ans, max(sa, sb))
	print(ans)


def solve(m, arr):
	(s1, s2) = (0, sum(arr[1]) - arr[1][-1])
	low = s2
	for i in range(m - 1)[::-1]:
		(s1, s2) = (s1 + arr[0][i + 1], s2 - arr[1][i])
		low = min(low, max(s1, s2))
	return low

def main():
	for _ in range(int(input())):
		m = int(input())
		arr = [[*map(int, input().split(' '))] for _ in range(2)]
		print(solve(m, arr))
main()


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sa = sum(a) - a[0]
	sb = 0
	r = sa
	for i in range(1, n):
		sa -= a[i]
		sb += b[i - 1]
		r = min(r, max(sa, sb))
	print(r)
for i in range(int(input())):
	solve()


import sys, os, io
from sys import stdin
import math
from collections import defaultdict
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
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')
alphabets = list('abcdefghijklmnopqrstuvwxyz')
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

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

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 sieveForSmallestPrimeFactor():
	MAXN = 100001
	spf = [0 for i in range(MAXN)]
	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, math.ceil(math.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
	return spf

def getPrimeFactorizationLOGN(x):
	spf = sieveForSmallestPrimeFactor()
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def SieveOfEratosthenes(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

def si():
	return input()

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

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

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')

def solve():
	n = ii()
	l = []
	for i in range(2):
		l.append(li())
	if n == 1:
		print(0)
		return
	u = [0] * n
	d = [0] * n
	u[-1] = l[0][-1]
	for i in range(n - 2, -1, -1):
		u[i] += u[i + 1] + l[0][i]
	d[0] = l[1][0]
	for i in range(1, n):
		d[i] += d[i - 1] + l[1][i]
	ans = float('inf')
	for i in range(1, n - 1):
		ans = min(ans, max(d[i - 1], u[i + 1]))
	ans = min(ans, d[-2], u[1])
	print(ans)
t = 1
t = ii()
for _ in range(t):
	solve()


for _ in range(int(input())):
	m = int(input())
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	s1[0] = 0
	s2[-1] = 0
	S1 = sum(s1)
	S2 = 0
	mn = max(S2, S1)
	for i in range(1, m):
		S1 -= s1[i]
		S2 += s2[i - 1]
		mn = min(mn, max(S2, S1))
	print(mn)


import sys
input = sys.stdin.readline

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

def inlt():
	return list(map(int, input().split()))
T = inp()
for i in range(T):
	m = inp()
	l1 = inlt()
	l2 = inlt()
	if m == 1:
		print(0)
	elif m == 2:
		print(min(l1[1], l2[0]))
	else:
		sum_row1 = {}
		sum_row2 = {}
		sum_row1[0] = l1[0]
		sum_row2[0] = l2[0]
		for j in range(1, m):
			sum_row1[j] = l1[j] + sum_row1[j - 1]
			sum_row2[j] = l2[j] + sum_row2[j - 1]
		max_score = sum_row1[m - 1] - sum_row1[0]
		index = 0
		for p in range(1, m):
			score = max(sum_row1[m - 1] - sum_row1[p], sum_row2[p - 1])
			if score < max_score:
				max_score = score
				index = p
		if index == 0:
			print(sum_row1[m - 1] - sum_row1[0])
		elif index == m - 1:
			print(sum_row2[m - 2])
		else:
			print(max(sum_row1[m - 1] - sum_row1[index], sum_row2[index - 1]))


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

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 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

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return [int(i) for i in input().split()]
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	m = int(input())
	d = []
	a = mapin()
	d.append(a)
	b = mapin()
	d.append(b)
	ans = 1e+20
	pre = [0] * m
	pre2 = [0] * m
	temp = 0
	temp2 = 0
	for i in range(m):
		temp += d[0][i]
		pre[i] = temp
		pre2[i] = temp2
		temp2 += d[1][i]
	temp = 0
	temp2 = 0
	for i in range(m - 1, -1, -1):
		temp += d[1][i]
		pre[i] += temp
		pre2[i] = max(pre2[i], temp2)
		temp2 += d[0][i]
	print(min(pre2))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	m = int(input())
	a = []
	for i in range(2):
		a.append(list(map(int, input().split())))
	ans = 1000000000000000.0
	sum1 = sum2 = 0
	for i in range(m):
		sum1 += a[0][i]
	for i in range(m):
		sum1 -= a[0][i]
		ans = min(ans, max(sum1, sum2))
		sum2 += a[1][i]
	print(ans)


import sys
tokens = ''.join(sys.stdin.readlines()).split()[::-1]

def next():
	return tokens.pop()

def nextInt():
	return int(next())

def nextFloat():
	return float(next())

def getIntArray(n):
	return [nextInt() for _ in range(n)]

def getFloatArray(n):
	return [nextFloat() for _ in range(n)]

def getStringArray(n):
	return [next() for _ in range(n)]
flush = sys.stdout.flush
testcase = True

def solve(testcase):
	N = nextInt()
	A = [getIntArray(N), getIntArray(N)]
	(S1, S2) = (sum(A[0]), 0)
	finalScore = max(S1 - A[0][0], sum(A[1]) - A[-1][-1])
	for i in range(N):
		S1 -= A[0][i]
		score = max(S1, S2)
		S2 += A[1][i]
		finalScore = min(finalScore, score)
	print(finalScore)
testcaseCount = nextInt() if testcase else 1
for tc in range(testcaseCount):
	solve(tc + 1)
assert not tokens


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


for _ in range(int(input())):
	m = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if m == 1:
		print(0)
		continue
	suma = sum(a) - a[0]
	sumb = 0
	minn = suma
	for i in range(1, m):
		suma -= a[i]
		sumb += b[i - 1]
		minn = min(minn, max(suma, sumb))
	print(minn)


import itertools
t = int(input())
for h in range(t):
	m = int(input())
	a = list(([], []))
	a[0] = list(map(int, input().split()))
	a[0].append(0)
	a[1] = list(map(int, input().split()))
	a[1].insert(0, 0)
	a[0] = a[0][::-1]
	k1 = list(itertools.accumulate(a[0]))
	k1.pop()
	k2 = list(itertools.accumulate(a[1]))
	k2.pop()
	k2 = k2[::-1]
	s = list(zip(k1, k2))
	s = min(list(map(max, s)))
	print(s)


def get_ans(mas1, mas2, m):
	sum1 = sum(mas1)
	sum2 = 0
	maxs = []
	for i in range(m):
		sum1 -= mas1[i]
		maxs.append(max(sum1, sum2))
		sum2 += mas2[i]
	return min(maxs)

def main():
	n = int(input())
	for i in range(n):
		m = int(input())
		mas1 = list(map(int, input().split()))
		mas2 = list(map(int, input().split()))
		res = get_ans(mas1, mas2, m)
		print(res)
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	m = int(input())
	coins = [[int(i) for i in input().split()] for j in range(2)]
	(row1, row2, ans) = (sum(coins[0]), 0, float('inf'))
	for i in range(m):
		row1 -= coins[0][i]
		if i != 0:
			row2 += coins[1][i - 1]
		ans = min(ans, max(row1, row2))
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = [list(map(int, input().split())) for i in range(2)]
	dp = [i[:] for i in a]
	for i in range(1, n):
		dp[0][i] += dp[0][i - 1]
	for i in range(n - 2, -1, -1):
		dp[1][i] += dp[1][i + 1]
	res = float('inf')
	for i in range(n):
		res = min(res, max(dp[0][n - 1] - dp[0][i], dp[1][0] - dp[1][i]))
	print(res)


tes = int(input())
for _ in range(tes):
	testnumber = int(input())
	temp1 = [int(i) for i in input().split()]
	temp2 = [int(i) for i in input().split()]
	thevalueforqianzhuihe = []
	thevalueforhouzhuihe = []
	for i in range(2):
		thevalueforqianzhuihe.append([])
		for j in range(testnumber):
			thevalueforqianzhuihe[i].append(0)
	for i in range(2):
		thevalueforhouzhuihe.append([])
		for j in range(testnumber):
			thevalueforhouzhuihe[i].append(0)
	thevaluefortestcase = [temp1, temp2]
	for i in range(2):
		isqianzhuihe = 0
		ishouzhuihe = 0
		for j in range(testnumber):
			thevalueforqianzhuihe[i][j] = isqianzhuihe
			isqianzhuihe = isqianzhuihe + thevaluefortestcase[i][j]
		for j in range(testnumber - 1, -1, -1):
			thevalueforhouzhuihe[i][j] = ishouzhuihe
			ishouzhuihe = ishouzhuihe + thevaluefortestcase[i][j]
	minoffinal = 10000000000.0
	for i in range(testnumber):
		minoffinal = min(minoffinal, max(thevalueforhouzhuihe[0][i], thevalueforqianzhuihe[1][i]))
	print(minoffinal)


t = int(input())
for i in range(t):
	c = []
	n = int(input())
	p = [int(x) for x in input().split()]
	p1 = [int(x) for x in input().split()]
	if n == 1:
		print(0)
		continue
	s = sum(p) - p[0]
	s1 = 0
	mi = max(s, s1)
	for j in range(1, n):
		s -= p[j]
		s1 += p1[j - 1]
		mx = max(s, s1)
		if mi > mx:
			mi = mx
	print(mi)


t = int(input())
for i in range(0, t):
	m = int(input())
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	sumlist = []
	arr = []
	arr.append(list1)
	arr.append(list2)
	sum1 = 0
	sum2 = 0
	for i in range(1, len(list1)):
		sum1 = sum1 + list1[i]
	sumlist.append(max(sum1, sum2))
	for i in range(1, len(list1)):
		sum1 = sum1 - list1[i]
		sum2 = sum2 + list2[i - 1]
		sumlist.append(max(sum1, sum2))
	print(min(sumlist))


from collections import deque as de
import math
from math import sqrt as sq
from math import floor as fl
from math import ceil as ce
from sys import stdin, stdout
import re
from collections import Counter as cnt
from functools import reduce
from itertools import groupby as gb
from bisect import bisect_left as bl, bisect_right as br

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

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binarytodecimal(n):
	return int(n, 2)

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def getProduct(n):
	product = 1
	while n != 0:
		product = product * (n % 10)
		n = n // 10
	return product

def lcm(x, y):
	lcm = x * y // math.gcd(x, y)
	return lcm

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def checkisap(list):
	d = list[1] - list[0]
	for i in range(2, len(list)):
		temp = list[i] - list[i - 1]
		if temp != d:
			return False
	return True

def primes_method5(n):
	out = {}
	sieve = [True] * (n + 1)
	for p in range(2, n + 1):
		if sieve[p]:
			out[p] = 1
			for i in range(p, n + 1, p):
				sieve[i] = False
	return out

def getSum(n):
	strr = str(n)
	list_of_number = list(map(int, strr.strip()))
	return sum(list_of_number)

def ceildiv(x, y):
	return (x + y - 1) // y

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

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

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

def si():
	return list(map(str, input()))

def indict():
	dic = {}
	for (index, value) in enumerate(input().split()):
		dic[int(value)] = int(index) + 1
	return dic

def frqdict():
	dic = {}
	for (index, value) in enumerate(input()):
		if value not in dic:
			dic[value] = 1
		else:
			dic[value] += 1
	return dic
t = ii()
while t:
	t -= 1
	n = ii()
	a = li()
	b = li()
	if n == 1:
		print(0)
	elif n == 2:
		print(min(a[1], b[0]))
	else:
		sumb = sum(b)
		suma = sum(a)
		tempa = suma - a[0]
		tempb = 0
		mn = max(tempa, tempb)
		for i in range(1, n):
			tempa -= a[i]
			tempb += b[i - 1]
			tempmax = max(tempa, tempb)
			if tempmax < mn:
				mn = tempmax
		print(mn)


t = int(input())
for i in range(t):
	n = int(input())
	lsta = list(map(int, input().split()))
	lstb = list(map(int, input().split()))
	prea = [lsta[0]]
	preb = [lstb[0]]
	for j in range(1, n):
		prea.append(prea[-1] + lsta[j])
		preb.append(preb[-1] + lstb[j])
	a = prea[-1] - prea[0]
	b = 0
	dif = a - b
	ind = 1
	lst1 = [max(a, b)]
	while True:
		if dif <= 0:
			break
		else:
			a = prea[-1] - prea[ind]
			b = preb[ind - 1]
			dif = a - b
			lst1.append(max(a, b))
			ind += 1
	if lst1 == []:
		print(0)
	else:
		print(min(lst1))


import math
for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	if n == 1:
		print(0)
		continue
	pref = [0] * n
	suff = [0] * n
	c = math.inf
	pref[0] = l1[0]
	suff[0] = l2[0]
	for x in range(1, n):
		pref[x] += pref[x - 1] + l1[x]
		suff[x] += suff[x - 1] + l2[x]
	for x in range(1, n - 1):
		k = max(pref[-1] - pref[x], suff[x - 1])
		c = min(c, k)
	c = min(c, pref[-1] - pref[0])
	c = min(c, suff[-2])
	print(c)


import sys
import math
import collections
from os import path
from collections import defaultdict
mod = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 6)
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
test = int(sys.stdin.readline().rstrip())
while test > 0:
	test -= 1
	n = int(sys.stdin.readline().rstrip())
	a = list(map(int, sys.stdin.readline().rstrip().split()))
	b = list(map(int, sys.stdin.readline().rstrip().split()))
	if n == 1:
		print(0)
	else:
		a1 = [0] * n
		s = 0
		for x in range(n):
			s += a[x]
			a1[x] = s
		b1 = [0] * n
		s = 0
		for x in range(n - 1, -1, -1):
			s += b[x]
			b1[x] = s
		ans = 10 ** 10
		for x in range(n):
			p = max(a1[n - 1] - a1[x], b1[0] - b1[x])
			if p < ans:
				ans = p
		print(ans)


import os
import sys
from io import BytesIO, IOBase
from itertools import accumulate
nmbr = lambda : int(input())
lst = lambda : list(map(int, input().split()))

def main():
	for _ in range(nmbr()):
		n = nmbr()
		f = lst()
		s = lst()
		pre = list(accumulate(f))
		suf = list(accumulate(s[::-1]))[::-1]
		ans = float('inf')
		for i in range(n):
			left = pre[i]
			right = suf[i]
			m1 = pre[-1] - left
			m2 = suf[0] - right
			ans = min(ans, max(m1, m2))
		sys.stdout.write(str(ans) + '\n')
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')
for t in range(1):
	main()


for _ in range(int(input())):
	m = int(input())
	row1 = [int(x) for x in input().split()]
	row2 = [int(x) for x in input().split()]
	s1 = sum(row1)
	s2 = sum(row2)
	alice = 0
	bob = 10000000000
	pref_sums1 = [0] * (m + 1)
	pref_sums2 = [0] * (m + 1)
	for i in range(m):
		pref_sums1[i + 1] = pref_sums1[i] + row1[i]
		pref_sums2[i + 1] = pref_sums2[i] + row2[i]
	for i in range(m):
		a = pref_sums1[i + 1] + pref_sums2[m] - pref_sums2[i]
		b = max(s1 - pref_sums1[i + 1], s2 - (pref_sums2[m] - pref_sums2[i]))
		if bob > b:
			bob = b
	print(bob)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, arr) = (int(input()), [])
	for _ in range(2):
		arr.append(list(map(int, input().split())))
	mx = 1000000000000000.0
	sum1 = sum2 = 0
	for i in range(n):
		sum1 += arr[0][i]
	for i in range(n):
		sum1 -= arr[0][i]
		mx = min(mx, max(sum1, sum2))
		sum2 += arr[1][i]
	print(mx)


def int_input():
	a = int(input())
	return a

def int_list_input():
	a = list(map(int, input().split()))
	return a

def solve():
	n = int_input()
	a = int_list_input()
	b = int_list_input()
	a_s = [0 for _ in range(n)]
	b_s = [0 for _ in range(n)]
	a_s[-1] = a[-1]
	for i in range(n - 2, -1, -1):
		a_s[i] = a_s[i + 1] + a[i]
	b_s[0] = b[0]
	for i in range(1, n):
		b_s[i] = b_s[i - 1] + b[i]
	ans = float('inf')
	for i in range(n):
		ans = min(ans, max(a_s[i] - a[i], b_s[i] - b[i]))
	print(ans)
for _ in range(int(input())):
	solve()


import sys
input = sys.stdin.readline
from itertools import accumulate
INF = 1 << 64
t = int(input())
for _ in range(t):
	m = int(input())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	aa1 = [0] + list(accumulate(a1))
	aa2 = [0] + list(accumulate(a2))
	ans = INF
	for i in range(1, m + 1):
		ans = min(ans, max(aa1[m] - aa1[i], aa2[i - 1]))
	print(ans)


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')
from collections import defaultdict
from math import ceil, floor, sqrt, log2, gcd, pi
from heapq import heappush, heappop
from fractions import Fraction
from bisect import bisect_left, bisect
import sys
abc = 'abcdefghijklmnopqrstuvwxyz'
ABC = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for i in range(int(input())):
	n = int(input())
	r1 = list(map(int, input().split()))
	r2 = list(map(int, input().split()))
	for i in range(n - 2, 0, -1):
		r1[i] += r1[i + 1]
	r1[0] = 0
	r2[-1] = 0
	for i in range(1, n - 1):
		r2[i] += r2[i - 1]
	if n == 1:
		print(0)
	elif n == 2:
		print(min(r1[-1], r2[0]))
	else:
		arr = []
		for i in range(n):
			if i == 0:
				arr.append(r1[1])
			elif i == n - 1:
				arr.append(r2[-2])
			else:
				arr.append(max(r1[i + 1], r2[i - 1]))
		arr.sort()
		print(min(arr))


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

def si():
	return input()

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

def msi():
	return map(str, input().split())

def li():
	return list(mi())
mod = 10 ** 9
t = ii()
for _ in range(t):
	m = ii()
	r1 = li()
	r2 = li()
	pre1 = [0] * m
	pre2 = [0] * m
	summ = sum(r1)
	for i in range(m):
		pre1[i] = pre1[i - 1] + r1[i]
		pre2[i] = pre2[i - 1] + r2[i]
	temp = 0
	ans = 10 ** 10
	for i in range(m):
		temp = max((summ - pre1[i]) % mod, (pre2[i] - r2[i]) % mod)
		ans = min(ans, temp) % mod
	print(ans % mod)


t = int(input())
for u in range(t):
	m = int(input())
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	if m == 1:
		print(0)
	else:
		pr1 = []
		su1 = 0
		for i in range(m):
			su1 += s1[i]
			pr1.append(su1)
		pr2 = []
		su2 = 0
		for i in range(m):
			su2 += s2[i]
			pr2.append(su2)
		mans = sum(s1) + sum(s2)
		for i in range(m):
			if i == 0:
				tans = pr1[-1] - pr1[0]
			elif i == m - 1:
				tans = pr2[m - 2]
			else:
				tans = max(pr2[i - 1], pr1[-1] - pr1[i])
			mans = min(tans, mans)
		print(mans)


for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(2):
		a.append(list(map(int, input().split())))
	sum1 = sum(a[0])
	sum2 = 0
	ans = 1000000007
	for i in range(n):
		sum1 -= a[0][i]
		ans = min(ans, max(sum1, sum2))
		sum2 += a[1][i]
	print(ans)


def coins(m, a, b):
	cabove = sum(a) - a[0]
	cbelow = 0
	prvc = sum(a) - a[0]
	result = prvc
	for i in range(1, m):
		cabove = cabove - a[i]
		cbelow = cbelow + b[i - 1]
		prvc = max(cbelow, cabove)
		result = min(prvc, result)
	return result
x = int(input())
m = []
for i in range(x):
	a = int(input())
	z = input()
	z1 = z.split(' ')
	z2 = [int(t) for t in z1]
	y = input()
	y1 = y.split(' ')
	y2 = [int(t) for t in y1]
	m.append((a, z2, y2))
for j in range(x):
	print(coins(m[j][0], m[j][1], m[j][2]))


for _ in range(int(input())):
	n = int(input())
	lis1 = list(map(int, input().split()))
	lis2 = list(map(int, input().split()))
	sum1 = sum(lis1) - lis1[0]
	sum2 = 0
	if n == 1:
		print(0)
		continue
	mini = 1000000007
	for i in range(n - 1):
		sums = [sum1, sum2]
		if max(sums) < mini:
			mini = max(sums)
		sum2 += lis2[i]
		sum1 -= lis1[i + 1]
		sums = [sum1, sum2]
	if max(sums) < mini:
		mini = max(sums)
	if mini == 1000000007:
		print(0)
	else:
		print(mini)


def solve(A, B, n):
	pref = [0]
	for it in B:
		pref.append(pref[-1] + it)
	suff = [0] * n
	cur = 0
	for i in range(n - 1, -1, -1):
		suff[i] = cur
		cur += A[i]
	ans = float('inf')
	for i in range(n):
		mn = max(pref[i], suff[i])
		ans = min(ans, mn)
	return ans
for case in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	ans = solve(A, B, n)
	print(ans)


from decimal import *
import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(x, y) = (0, n - 1)
	(a1, a2) = (0, 0)
	while x != y:
		if a1 + b[x] <= a2 + a[y]:
			a1 += b[x]
			x += 1
		else:
			a2 += a[y]
			y -= 1
	print(max(a1, a2))


test = int(input())
for i in range(test):
	m = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	e = []
	c = sum(a)
	d = 0
	for j in range(m):
		if j == 0:
			c = c - a[j]
		else:
			c = c - a[j]
			d = d + b[j - 1]
		e.append(max(c, d))
	print(min(e))


import math
t = int(input())
while t:
	m = int(input())
	final = math.inf
	array_1 = list(map(int, input().split()))
	array_2 = list(map(int, input().split()))
	mi = math.inf
	a_sum = sum(array_1)
	a = 0
	b_sum = sum(array_2)
	b = b_sum
	for i in range(m):
		a += array_1[i]
		if max(a_sum - a, b_sum - b) <= final:
			final = max(a_sum - a, b_sum - b)
		b -= array_2[i]
	print(final)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 0
	pref = [0] * n
	pref2 = [0] * n
	pref[0] = a[0]
	pref2[0] = b[0]
	for i in range(1, n):
		pref[i] = pref[i - 1] + a[i]
		pref2[i] = pref2[i - 1] + b[i]
	pref2.append(0)
	m = 100000000000000
	for i in range(n):
		x = max(pref[-1] - pref[i], pref2[i - 1])
		m = min(m, x)
	if n == 1:
		print(0)
	else:
		print(m)


from collections import defaultdict as dd
import math
import sys
input = sys.stdin.readline

def nn():
	return int(input())

def li():
	return list(input())

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

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

def solve():
	m = nn()
	r1 = lm()
	r2 = lm()
	best = sum(r1) + sum(r2)
	above = sum(r1) - r1[0]
	below = 0
	cur = max(above, below)
	best = min(cur, best)
	for i in range(m - 1):
		below += r2[i]
		above -= r1[i + 1]
		cur = max(above, below)
		best = min(cur, best)
	print(best)
q = nn()
for _ in range(q):
	solve()


import sys
import math
import heapq
from collections import defaultdict as dd
from collections import OrderedDict as od
from collections import deque
from itertools import permutations as pp
from itertools import combinations as cc
from sys import stdin
from functools import cmp_to_key
from functools import lru_cache
from bisect import bisect_left as bs_l
from bisect import bisect_right as bs_r
input = sys.stdin.readline
mod = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 5)
T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	(asuf, bpref) = ([0] * (n + 1), [0] * (n + 1))
	for i in range(1, n + 1):
		asuf[i] = asuf[i - 1] + arr[n - i]
		bpref[i] = bpref[i - 1] + brr[i - 1]
	asuf = asuf[::-1]
	ans = 10 ** 9
	for i in range(n):
		aa = asuf[i + 1]
		bb = bpref[i]
		ans = min(ans, max(aa, bb))
	print(ans)


def accumulate2(a):
	import itertools
	return tuple(itertools.chain((0,), itertools.accumulate(a)))[:-1]
for _ in range(int(input())):
	m = int(input())
	a1sums = accumulate2(tuple(map(int, input().split()))[::-1])[::-1]
	a2sums = accumulate2(map(int, input().split()))
	print(min(map(max, zip(a1sums, a2sums))))


def naiveSolve():
	return

def solve():
	return

def main():
	t = int(input())
	allans = []
	for _ in range(t):
		n = int(input())
		a1 = readIntArr()
		a2 = readIntArr()
		p1 = a1.copy()
		p2 = a2.copy()
		for i in range(1, n):
			p1[i] += p1[i - 1]
			p2[i] += p2[i - 1]

		def q(p, l, r):
			if r < 0:
				return 0
			if l >= n:
				return 0
			if l == 0:
				return p[r]
			return p[r] - p[l - 1]
		ans = inf
		for i in range(n):
			ans = min(ans, max(q(p2, 0, i - 1), q(p1, i + 1, n - 1)))
		allans.append(ans)
	multiLineArrayPrint(allans)
	return
import sys
input = sys.stdin.buffer.readline

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(x):
	print('{}'.format(x))
	sys.stdout.flush()
	return int(input())

def answerInteractive(ans):
	print('! {}'.format(ans))
	sys.stdout.flush()
inf = float('inf')
MOD = 998244353
from math import gcd, floor, ceil
for _abc in range(1):
	main()


for t in range(int(input())):
	m = int(input())
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	shag1 = m - 1
	shag2 = 0
	grivna1 = 0
	grivna2 = 0
	while shag1 != shag2:
		if grivna1 + s1[shag1] < grivna2 + s2[shag2]:
			grivna1 += s1[shag1]
			shag1 -= 1
		else:
			grivna2 += s2[shag2]
			shag2 += 1
	print(max(grivna1, grivna2))


T = int(input())
out = []
for t in range(T):
	m = int(input())
	a1 = [int(x) for x in input().split()]
	a2 = [int(x) for x in input().split()]
	(pre1, pre2) = ([a1[0]], [a2[0]])
	if m == 1:
		out.append(0)
		continue
	suf1 = [a1[-1]]
	for i in range(1, m):
		pre2.append(pre2[-1] + a2[i])
	for i in range(m - 2, -1, -1):
		suf1.append(suf1[-1] + a1[i])
	suf1 = suf1[::-1]
	bob = float('inf')
	opt1 = 0
	for i in range(m):
		if i < m - 1 and i > 0:
			ans = max(suf1[i + 1], pre2[i - 1])
		elif i < m - 1:
			ans = suf1[i + 1]
		else:
			ans = pre2[i - 1]
		if ans < bob:
			opt1 = i
			bob = ans
	out.append(bob)
for e in out:
	print(e)


for _ in range(int(input())):
	n = int(input())
	a = []
	for _ in range(2):
		a.append(list(map(int, input().split())))
	l = []
	for i in range(2):
		s = [0] * (n + 1)
		for j in range(n):
			s[j + 1] = s[j] + a[i][j]
		l.append(s)
		ans = float('inf')
	for i in range(n):
		b = max(l[0][-1] - l[0][i + 1], l[1][i])
		ans = min(ans, b)
	print(ans)


import sys
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def LI1():
	return list(map(int1, sys.stdin.readline().split()))

def LLI1(rows_number):
	return [LI1() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline().rstrip()
inf = 10 ** 16
md = 10 ** 9 + 7

def tocs(aa):
	res = [0]
	for a in aa:
		res.append(res[-1] + a)
	return res

def solve():
	n = II()
	aa = LI()
	bb = LI()
	ll = tocs(aa[::-1])
	rr = tocs(bb)
	ans = inf
	for c in range(n):
		cur = max(ll[c], rr[n - 1 - c])
		if cur < ans:
			ans = cur
	print(ans)
for testcase in range(II()):
	solve()


from sys import stdin
input = stdin.readline
rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input().strip()
YN = lambda x: print('YES') if x else print('NO')
mod = 10 ** 9 + 7
from itertools import accumulate
for _ in range(rn()):
	n = rn()
	top = rl()
	bottom = rl()
	if n == 1:
		print(0)
	else:
		top = list(accumulate(top[::-1]))[::-1]
		bottom = list(accumulate(bottom))
		ans = float('inf')
		for i in range(1, n):
			if i == 1:
				ans = min(ans, top[i])
			else:
				ans = min(ans, max(top[i], bottom[i - 2]))
		ans = min(ans, bottom[-2])
		print(ans)


T = int(input())
for t in range(T):
	m = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	A = [a, b]
	sufsumA = [0 for i in range(m)]
	sufsumB = [0 for i in range(m)]
	prefsumA = [0 for i in range(m)]
	prefsumB = [0 for i in range(m)]
	for i in range(m - 1, -1, -1):
		if i == m - 1:
			sufsumA[i] = 0
			sufsumB[i] = A[1][i]
		else:
			sufsumA[i] = sufsumA[i + 1] + A[0][i + 1]
			sufsumB[i] = sufsumB[i + 1] + A[1][i]
	for i in range(m):
		if i == 0:
			prefsumB[i] = 0
			prefsumA[i] = A[0][i]
		else:
			prefsumB[i] = prefsumB[i - 1] + A[1][i - 1]
			prefsumA[i] = prefsumA[i - 1] + A[0][i]
	ans = 0
	bestalice = 0
	bestbob = 100000000000
	scoreofalice = 0
	scoreofbob = bestbob
	for i in range(m):
		scoreofalice = prefsumA[i] + sufsumB[i]
		scoreofbob = max(prefsumB[i], sufsumA[i])
		if scoreofbob < bestbob:
			bestbob = scoreofbob
			ans = bestbob
	print(ans)


def solve(m, mat):
	ans = 1e+18
	topsum = sum(mat[0])
	botsum = 0
	for i in range(m):
		if i > 0:
			botsum += mat[1][i - 1]
		topsum -= mat[0][i]
		ans = min(ans, max(topsum, botsum))
	return ans
for t in range(int(input())):
	m = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve(m, [a, b]))


def main():
	for P in range(int(input())):
		iloL = int(input())
		listG = list(map(int, input().split()))
		listD = list(map(int, input().split()))
		(sumD, sumG) = (0, sum(listG) - listG[0])
		wyn = sumG
		for i in range(1, iloL):
			sumG -= listG[i]
			sumD += listD[i - 1]
			wyn = min(wyn, max(sumG, sumD))
		print(wyn)
main()


def solution(m, row1: list, row2: list) -> int:
	if m == 1:
		return 0
	row1[0] = 0
	row2[-1] = 0
	a = []
	b = []
	sm1 = 0
	sm2 = 0
	for (c1, c2) in zip(row1, row2):
		sm1 += c1
		sm2 += c2
		a.append(sm1)
		b.append(sm2)
	mn = min(a[-1] - a[0], b[m - 2])
	for i in range(1, m - 1):
		current = max(b[i - 1], a[m - 1] - a[i])
		if current < mn:
			mn = current
	return mn

def main():
	for _ in range(int(input())):
		m = int(input())
		row1 = list(map(int, input().split()))
		row2 = list(map(int, input().split()))
		print(solution(m, row1, row2))
main()


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	a = [list(map(int, input().strip().split())) for i in range(2)]
	pref0 = [a[0][0]]
	pref1 = [a[1][0]]
	for i in range(1, n):
		pref0 += [pref0[-1] + a[0][i]]
		pref1 += [pref1[-1] + a[1][i]]
	pref0 = [0] + pref0
	pref1 = [0] + pref1
	ans = 10 ** 100
	for i in range(n):
		ans = min(ans, max(pref0[-1] - pref0[i + 1], pref1[i] - pref1[0]))
	print(ans)
for _ in range(int(input())):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	for _ in range(2):
		a.append(list(map(int, input().split())))
	ans = float('inf')
	(sum1, sum2) = (0, 0)
	for i in range(n):
		sum1 += a[0][i]
	for i in range(n):
		sum1 -= a[0][i]
		ans = min(ans, max(sum1, sum2))
		sum2 += a[1][i]
	print(ans)


t = int(input())
for _ in range(t):
	m = int(input())
	a = [list(map(int, input().split())) for i in range(2)]
	if m == 1:
		print(0)
		continue
	(t_l, t_r) = (0, 0)
	(L, R) = (0, m - 1)
	while L != R:
		if t_l <= t_r:
			t_l += a[1][L]
			L += 1
		else:
			t_r += a[0][R]
			R -= 1
	M = max(t_l, t_r)
	if L > 0:
		M = min(M, max(t_l - a[1][L - 1], t_r + a[0][R]))
	if R < m - 1:
		M = min(M, max(t_l + a[1][L], t_r - a[0][R + 1]))
	print(M)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	m = int(input())
	c = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = [0 for i in range(m)]
	e = [0 for i in range(m)]
	d[0] = b[0]
	e[m - 1] = c[m - 1]
	for i in range(1, m):
		d[i] = d[i - 1] + b[i]
	for i in range(m - 2, -1, -1):
		e[i] = e[i + 1] + c[i]
	an = min(sum(c[1:m]), sum(b[:m - 1]))
	for i in range(1, m - 1):
		an = min(an, max(d[i - 1], e[i + 1]))
	print(an)


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
import bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

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

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def S_():
	return input()

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

def LS():
	return [i for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def NLI(n):
	return [[int(i) for i in input().split()] for i in range(n)]

def NLI_(n):
	return [[int(i) - 1 for i in input().split()] for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def INP():
	N = 9
	n = random.randint(1, N)
	A = [random.randint(1, n) for i in range(m)]
	return (n, A)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		a1 = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print(inp)
			print('naive', a1)
			print('solve', a2)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

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

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = 1 << 63
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
alp = [chr(ord('a') + i) for i in range(26)]
show_flg = False
show_flg = True

def primeFactor(N):
	(i, n) = (2, N)
	ret = {}
	(d, sq) = (2, 99)
	while i <= sq:
		k = 0
		while n % i == 0:
			(n, k, ret[i]) = (n // i, k + 1, k + 1)
		if k > 0 or i == 97:
			sq = int(n ** (1 / 2) + 0.5)
		if i < 4:
			i = i * 2 - 1
		else:
			(i, d) = (i + d, d ^ 6)
	if n > 1:
		ret[n] = 1
	return ret

def divisors(n):
	div = [1]
	for (i, j) in primeFactor(n).items():
		div = [i ** k * d for d in div for k in range(j + 1)]
	return div

def sieve(x):
	s = [i for i in range(x + 1)]
	p = 2
	while p * p <= x:
		if s[p] == p:
			for q in range(2 * p, x + 1, p):
				if s[q] == q:
					s[q] = p
		p += 1
	return s

def PrimeNumSet(N):
	M = int(N ** 0.5)
	seachList = [i for i in range(2, N + 1)]
	primes = []
	while seachList:
		if seachList[0] > M:
			break
		primes.append(seachList[0])
		tmp = seachList[0]
		seachList = [i for i in seachList if i % tmp != 0]
	return primes + seachList

def LCM(b, mo=10 ** 9 + 7):
	prs = PrimeNumSet(max(b))
	M = dict(zip(prs, [0] * len(prs)))
	for i in b:
		dc = primeFactor(i)
		for (j, k) in dc.items():
			M[j] = max(M[j], k)
	r = 1
	for (j, k) in M.items():
		if k != 0:
			r *= pow(j, k, mo)
			r %= mo
	return r

def extgcd(x, y):
	if y == 0:
		return (1, 0)
	(r0, r1, s0, s1) = (x, y, 1, 0)
	while r1 != 0:
		(r0, r1, s0, s1) = (r1, r0 % r1, s1, s0 - r0 // r1 * s1)
	return (s0, (r0 - s0 * x) // y, x * s0 + y * (r0 - s0 * x) // y)

def crt(rems, mods):
	n = len(rems)
	if n != len(mods):
		return NotImplemented
	(x, d) = (0, 1)
	for (r, m) in zip(rems, mods):
		(a, b, g) = extgcd(d, m)
		(x, d) = ((m * b * x + d * a * r) // g, d * (m // g))
		x %= d
	for (r, m) in zip(rems, mods):
		if r != x % m:
			return (-1, d)
	return (x, d)

def intsqrt(x):
	if x < 0:
		return NotImplemented
	rt = int(x ** 0.5) - 1
	while (rt + 1) ** 2 <= x:
		rt += 1
	return rt
ans = 0
for _ in range(I()):
	n = I()
	a = LI()
	b = LI()
	ans = d = sum(b[:n - 1])
	u = 0
	for i in range(n - 2, -1, -1):
		d -= b[i]
		u += a[i + 1]
		ans = min(ans, max(u, d))
	print(ans)


for _ in range(int(input())):
	m = int(input())
	field = []
	for i in range(2):
		field.append(list(map(int, input().split())))
	up = [0 for i in range(m)]
	a = 0
	for i in range(m - 1):
		a += field[0][m - i - 1]
		up[m - i - 2] = a
	down = [0 for i in range(m)]
	a = 0
	for i in range(m - 1):
		a += field[1][i]
		down[i + 1] = a
	ans = 10 ** 9
	for i in range(m):
		ans = min(ans, max(down[i], up[i]))
	print(ans)


t = int(input())
for _ in range(t):
	m = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = sum(a)
	z = 0
	za = 10 ** 10
	for j in range(m):
		za = min(za, max(s - a[j], z))
		s -= a[j]
		z += b[j]
	print(za)


for t in range(int(input())):
	m = int(input())
	a2 = list(map(int, input().split()))
	a1 = list(map(int, input().split()))
	p = [0]
	s = [sum(a2)]
	for v in a1:
		p.append(p[-1] + v)
	for v in a2:
		s.append(s[-1] - v)
	ans = 10 ** 18
	for i in range(m):
		ans = min(ans, max(p[i], s[i + 1]))
	print(ans)


t = int(input())
while t:
	n = int(input())
	res = []
	res.append(list(map(int, input().split())))
	res.append(list(map(int, input().split())))
	res1 = []
	summ = 0
	res1.append(0)
	for i in range(n - 1, 0, -1):
		summ += res[0][i]
		res1.append(summ)
	res1 = res1[::-1]
	summ = 0
	res2 = []
	res2.append(0)
	for i in range(n - 1):
		summ += res[1][i]
		res2.append(summ)
	minn = max(res1[0], res2[0])
	for i in range(1, n):
		if max(res1[i], res2[i]) < minn:
			minn = max(res1[i], res2[i])
	print(minn)
	t -= 1


n = int(input())
while n > 0:
	ans = []
	n -= 1
	m = int(input())
	for i in range(2):
		s = [int(i) for i in input().split()]
		ans.append(s)
	if m == 1:
		print(0)
	else:
		dp = [0] * m
		dp[0] = sum(ans[0][1:])
		a = 0
		b = sum(ans[0][1:])
		for i in range(1, m):
			a += ans[1][i - 1]
			b -= ans[0][i]
			dp[i] = max(b, a)
		print(min(dp))


t = int(input())
for task in range(t):
	m = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = sum(a) - a[0]
	sumA = res
	sumB = 0
	for i in range(1, m):
		sumA -= a[i]
		sumB += b[i - 1]
		tmp = max(sumA, sumB)
		if tmp < res:
			res = tmp
	print(res)


import sys
import math
from math import *
import builtins
import collections
import bisect
import os
from io import BytesIO, IOBase

def print(x, end='\n'):
	sys.stdout.write(str(x) + end)

def get_int():
	return int(input())

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

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

def get_tuple_ints():
	return tuple(map(int, input().split()))

def print_iterable(p):
	print(' '.join(map(str, p)))

def CountFrequency(arr):
	return collections.Counter(arr)

def reverse(s):
	l = len(s)
	for i in range(l // 2):
		(s[i], s[l - i - 1]) = (s[l - i - 1], s[i])
	return s

def binary_search(arr, x):
	low = 0
	high = len(arr) - 1
	mid = 0
	while low <= high:
		mid = (high + low) // 2
		if arr[mid] < x:
			low = mid + 1
		elif arr[mid] > x:
			high = mid - 1
		else:
			return mid
	return high

def lower_bound(arr, x):
	return bisect.bisect_left(arr, x, lo=0, hi=len(arr))

def upper_bound(arr, x):
	return bisect.bisect_right(arr, x, lo=0, hi=len(arr))

def position(x):
	return ord(x) - ord('a') + 1

def pow(a, n):
	if n == 0:
		return 1
	elif n % 2 == 0:
		return pow(a, n // 2) % const * (pow(a, n // 2) % const) % const
	else:
		return pow(a, n // 2) % const * (pow(a, n // 2) % const) * (a % const) % const
R = 3
C = 3

def main():
	n = get_int()
	for i in range(n):
		m = get_int()
		row1 = get_list_ints()
		row2 = get_list_ints()
		slist = [0]
		for i in range(m - 1):
			slist.append(slist[-1] + row2[i])
		slist2 = [0]
		for i in range(m - 1, 0, -1):
			slist2.append(slist2[-1] + row1[i])
		slist2 = reverse(slist2)
		anslist = []
		for i in range(m):
			anslist.append(max(slist[i], slist2[i]))
		print(min(anslist))
	pass
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()


import sys
input = sys.stdin.readline

def dub(i, a1, a2):
	m = len(a1)
	if i == 0:
		return a1[m - 1] - a1[0]
	return max(a2[i - 1], a1[m - 1] - a1[i])

def solve():
	m = int(input())
	a1 = [int(x) for x in input().split()]
	a2 = [int(x) for x in input().split()]
	for i in range(1, m):
		a1[i] += a1[i - 1]
	for i in range(1, m):
		a2[i] += a2[i - 1]
	ans = 1e+20
	for i in range(m):
		ans = min(ans, dub(i, a1, a2))
	return ans
t = int(input())
for _ in range(t):
	print(solve())


T = int(input())
for t in range(T):
	n = int(input())
	arr = [list(map(int, input().split())) for i in range(2)]
	upper_row = sum(arr[0])
	suf = upper_row - arr[0][0]
	pre = 0
	mn = 10000000000000
	mn = min(max(pre, suf), mn)
	for i in range(1, n):
		suf -= arr[0][i]
		pre += arr[1][i - 1]
		ans = max(suf, pre)
		mn = min(ans, mn)
	print(mn)


t = int(input())
for k in range(t):
	n = int(input())
	l = []
	for i in range(2):
		tmp = list(map(int, input().split()))
		l.append(tmp)
	r1 = sum(l[0])
	r2 = sum(l[1])
	res = [r1 - l[0][0], r2 - l[1][n - 1]]
	a = r1 - l[0][0]
	b = 0
	for i in range(n - 2):
		a -= l[0][i + 1]
		b += l[1][i]
		res.append(max(a, b))
	print(min(res))


from sys import stdin
input = stdin.buffer.readline

def func():
	pref_up = [mat[0][0]]
	pref_down = [mat[1][0]]
	for i in range(1, m):
		pref_up.append(pref_up[-1] + mat[0][i])
		pref_down.append(pref_down[-1] + mat[1][i])
	rem = 10000000000.0
	for i in range(m):
		rem = min(rem, max(pref_up[-1] - pref_up[i], pref_down[i] - mat[1][i]))
	print(rem)
for _ in range(int(input())):
	m = int(input())
	mat = list()
	mat.append(list(map(int, input().split())))
	mat.append(list(map(int, input().split())))
	func()


from math import *
t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	a.append(list(map(int, input().split())))
	a.append(list(map(int, input().split())))
	pre = [a[0][-1]]
	for i in range(n - 2, -1, -1):
		pre.append(pre[-1] + a[0][i])
	pre = pre[::-1]
	suf = [a[1][0]]
	for i in range(1, n):
		suf.append(suf[-1] + a[1][i])
	ans = 10 ** 20
	if n == 1:
		print(0)
		continue
	for i in range(n):
		if i == 0:
			ans = min(ans, pre[i + 1])
		elif i == n - 1:
			ans = min(ans, suf[i - 1])
		else:
			ans = min(ans, max(pre[i + 1], suf[i - 1]))
	print(ans)


import heapq
from collections import defaultdict, deque
from itertools import accumulate
from math import inf
MOD = 10 ** 9 + 7
t = int(input())

def solve():
	m = int(input())
	n = 2
	G = []
	for _ in range(2):
		row = list(map(int, input().split()))
		G.append(row)
	paths = [0] * m
	ps_upper = list(accumulate(G[0]))
	ps_lower = list(accumulate(G[1]))
	for i in range(m):
		if i > 0:
			paths[i] = max(ps_upper[m - 1] - ps_upper[i], ps_lower[max(0, i - 1)])
		else:
			paths[i] = max(ps_upper[m - 1] - ps_upper[i], 0)
	return min(paths)
for _ in range(t):
	sol = solve()
	print(sol)


def maxCoin(dp, total):
	mx = float('-inf')
	mn = float('inf')
	for i in range(m):
		mx = max(mx, dp[0][i] + dp[1][i])
		mn = min(mn, max(total - dp[0][i], dp[1][0] - dp[1][i]))
	return (mx, mn)
t = int(input())
for _ in range(t):
	m = int(input())
	arr = []
	for k in range(2):
		arr.append(list(map(int, input().split())))
	dp = [[0 for i in range(m)] for j in range(2)]
	(x, y) = (0, 0)
	for i in range(m - 1, -1, -1):
		y += arr[0][m - i - 1]
		x += arr[1][i]
		(dp[0][m - i - 1], dp[1][i]) = (y, x)
	total = sum(arr[0])
	(mx, mn) = maxCoin(dp, total)
	print(mn)


import sys
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()

def li():
	return [int(i) for i in input().split()]

def lli(rows):
	return [li() for _ in range(rows)]

def si():
	return input()

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

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

def solve():
	m = II()
	a = []
	for i in range(2):
		a.append(LI())
	t1 = [0]
	t2 = [a[1][-1]]
	t3 = [0]
	for i in range(m - 1):
		t1.append(t1[-1] + a[0][-1 - i])
	t1.reverse()
	for i in range(m - 1):
		t3.append(t3[-1] + a[1][i])
	bs = 0
	tt = []
	for i in range(m):
		tt.append(max(t3[i], t1[i]))
	return min(tt) if len(tt) > 0 else 0

def main():
	for _ in range(II()):
		sys.stdout.write(str(solve()) + '\n')
main()


t = int(input())
for _ in range(t):
	m = int(input())
	a = [list(map(int, input().split())) for _ in range(2)]
	r = [[0], [0]]
	for i in range(2):
		for j in range(m):
			r[i].append(r[i][j] + a[i][j])
	ans = 10 ** 10
	for i in range(m):
		ans = min(ans, max(r[1][i], r[0][m] - r[0][i + 1]))
	print(ans)


sr = lambda : input()
ir = lambda : int(sr())
lr = lambda : list(map(int, sr().split()))
inf = 10 ** 18
mod = 998244353
test = ir()
for t in range(test):
	m = ir()
	a1 = lr()
	a2 = lr()
	aa1 = [0]
	aa2 = [0]
	for i in range(m):
		aa1.append(aa1[-1] + a1[i])
		aa2.append(aa2[-1] + a2[i])
	ans = inf
	pre = 0
	for i in range(m):
		uans = aa1[m] - aa1[i + 1]
		dans = aa2[i] - aa2[0]
		pre = max(uans, dans)
		ans = min(ans, pre)
	print(ans)


import sys
from itertools import accumulate

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

def MI():
	return map(int, sys.stdin.readline().rstrip().split())

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

def LI2():
	return list(map(int, sys.stdin.readline().rstrip()))

def S():
	return sys.stdin.readline().rstrip()

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

def LS2():
	return list(sys.stdin.readline().rstrip())
t = I()
for _ in range(t):
	m = I()
	A = [LI() for _ in range(2)]
	SA0 = list(accumulate([0] + A[0]))
	SA1 = list(accumulate([0] + A[1]))
	ans = 10 ** 18
	for j in range(1, m + 1):
		a = max(SA0[-1] - SA0[j], SA1[j - 1])
		ans = min(ans, a)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	sm = sum(l1)
	ld1 = [l1[0]]
	for i in range(1, n):
		ld1.append(ld1[-1] + l1[i])
	ld1.append(0)
	ld2 = [l2[0]]
	for i in range(1, n):
		ld2.append(ld2[-1] + l2[i])
	ld2.insert(0, 0)
	mn = 1000000000
	i = 0
	while i < n:
		mn = min(mn, max(sm - ld1[i], ld2[i]))
		i += 1
	print(mn)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = input().split()
	a = [int(x) for x in s]
	s = input().split()
	b = [int(x) for x in s]
	su = 0
	suma = []
	sumb = []
	for x in a:
		su += x
		suma.append(su)
	ans = su
	su = 0
	for x in b:
		su += x
		sumb.append(su)
	ans = ans + su + 10
	ansIndex = 0
	ansb = ans
	for i in range(n):
		tempa = 0
		tempb = 0
		if i == 0:
			tempa = sumb[n - 1] + suma[0]
			tempb = suma[n - 1] - suma[0]
		elif i == n - 1:
			tempa = suma[n - 1] + b[n - 1]
			if n > 1:
				tempb = sumb[n - 2]
		else:
			tempa = suma[i] + sumb[n - 1] - sumb[i - 1]
			tempb = max(sumb[i - 1], suma[n - 1] - suma[i])
		if tempb < ansb:
			ansb = tempb
	print(ansb)


for _ in range(int(input())):
	m = int(input())
	ls1 = list(map(int, input().split()))
	ls2 = list(map(int, input().split()))
	if m == 1:
		print(0)
	else:
		sumt = sum(ls1) + sum(ls2)
		for i in range(1, m):
			ls1[i] = ls1[i] + ls1[i - 1]
		for i in range(m - 2, -1, -1):
			ls2[i] = ls2[i] + ls2[i + 1]
		rs = min(ls1[m - 1] - ls1[0], ls2[0] - ls2[m - 1])
		for i in range(1, m - 1):
			rs = min(rs, max(ls1[m - 1] - ls1[i], ls2[0] - ls2[i]))
		print(rs)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	str1 = input().split()
	str1 = [int(x) for x in str1]
	str2 = input().split()
	str2 = [int(x) for x in str2]
	qun1 = []
	qun2 = []
	temp1 = 0
	temp2 = 0
	for j in range(0, n):
		temp1 += str1[j]
		qun1.append(temp1)
		temp2 += str2[j]
		qun2.append(temp2)
	ans = qun1[n - 1] + qun2[n - 1]
	for ii in range(n):
		if ii == n - 1:
			ans1 = 0
		else:
			ans1 = qun1[n - 1] - qun1[ii]
		if ii == 0:
			ans2 = 0
		else:
			ans2 = qun2[ii - 1]
		ans3 = max(ans1, ans2)
		ans = min(ans, ans3)
	print(ans)


for _ in range(int(input().strip())):
	cols = int(input().strip())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	(l, u, ans) = (0, sum(a), 1000000000.0)
	for i in range(cols):
		u -= a[i]
		ans = min(ans, max(u, l))
		l += b[i]
	print(ans)


ans = []
for _ in range(int(input())):
	n = int(input())
	a = [0] + list(map(int, input().split()))
	b = [0] + list(map(int, input().split()))
	for i in range(1, n + 1):
		a[i] += a[i - 1]
		b[i] += b[i - 1]
	mn = 10 ** 10
	for i in range(1, n + 1):
		cur = max(b[i - 1], a[-1] - a[i])
		mn = min(mn, cur)
	ans.append(mn)
print('\n'.join(map(str, ans)))


t = int(input())
for _ in range(t):
	m = int(input())
	row1 = list(map(int, input().split()))
	row2 = list(map(int, input().split()))
	topsum = sum(row1)
	bottomsum = 0
	answer = float('inf')
	for i in range(m):
		topsum -= row1[i]
		answer = min(answer, max(topsum, bottomsum))
		bottomsum += row2[i]
	print(answer)


for _ in range(int(input())):
	m = int(input())
	field = tuple((tuple(map(int, input().split())), tuple(map(int, input().split()))))
	(a, b) = (sum(field[0][1:]), 0)
	for (a_part, b_part) in zip(field[0][1:], field[1][:-1]):
		if max(a - a_part, b + b_part) > max(a, b):
			break
		a -= a_part
		b += b_part
	print(max(a, b))


def solve(n, board):
	bob_score = [0] * n
	bot = 0
	top = sum(board[0])
	for i in range(n):
		top -= board[0][i]
		bob_score[i] = max(bot, top)
		bot += board[1][i]
	return min(bob_score)
import os
import io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input().decode().strip())
for t in range(T):
	n = int(input().decode().strip())
	row1 = [int(x) for x in input().decode().strip().split(' ')]
	row2 = [int(x) for x in input().decode().strip().split(' ')]
	res1 = solve(n, [row1, row2])
	print(res1)


import sys
import math
lines = []
is_stdin = False
is_stdin = True
if is_stdin:
	for line in sys.stdin:
		lines.append(line.strip())
else:
	with open('./input1.txt', 'r') as f:
		for line in f.readlines():
			lines.append(line.strip())
N = int(lines.pop(0))
while N > 0:
	N -= 1
	n = int(lines.pop(0))
	a = lines.pop(0).split(' ')
	arr_a = [int(x) for x in a]
	b = lines.pop(0).split(' ')
	arr_b = [int(x) for x in b]
	sum_a = sum(arr_a)
	top_right = sum_a
	bottom_left = 0
	a_min_b = None
	for i in range(0, len(arr_a)):
		top_right -= arr_a[i]
		if i > 0:
			bottom_left += arr_b[i - 1]
		cur_b_max = max(top_right, bottom_left)
		if a_min_b is None:
			a_min_b = cur_b_max
		elif cur_b_max < a_min_b:
			a_min_b = cur_b_max
	print(a_min_b)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s1 = sum(a)
	s2 = 0
	ans = 10 ** 9
	for i in range(n):
		s1 = s1 - a[i]
		ans = min(ans, max(s1, s2))
		s2 = s2 + b[i]
	print(ans)


import atexit, io, sys, collections, math, heapq, fractions, copy, os, functools
import sys
import random
import collections
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')

def f(mat):
	if len(mat[0]) == 1:
		return 0
	ans = 10 ** 10
	cumul = 0
	dp2 = [0 for ii in range(len(mat[0]))]
	for i in range(len(mat[0]) - 1):
		cumul += mat[1][i]
		dp2[i] = cumul
	dp1 = [0 for ii in range(len(mat[0]))]
	cumul = 0
	for i in range(len(mat[0]) - 1, 0, -1):
		cumul += mat[0][i]
		dp1[i] = cumul
	for i in range(-1, len(mat[0]) - 1):
		uu = dp2[i] if i >= 0 else 0
		vv = dp1[i + 2] if i + 2 < len(dp1) else 0
		ans = min(ans, max(uu, vv))
	return ans
for u in range(int(input())):
	m = int(input())
	mat = [list(map(int, input().split())) for _ in range(2)]
	print(f(mat))


import sys
input = sys.stdin.readline

def solve():
	m = int(input())
	arr = [list(map(int, input().split())) for _ in range(2)]
	(ps1, ps2) = ([0] * m, [0] * m)
	v1 = v2 = 0
	for i in range(m):
		v1 += arr[0][i]
		v2 += arr[1][i]
		ps1[i] += v1
		ps2[i] += v2
	ans = min(ps1[-1] - ps1[0], ps2[-1] - arr[1][-1])
	for i in range(1, m - 1):
		ans = min(ans, max(ps2[i - 1], ps1[-1] - ps1[i]))
	return ans
for _ in range(int(input())):
	print(solve())


import sys
input_file = sys.stdin
output_file = sys.stdout
for i in range(int(input_file.readline())):
	n = int(input_file.readline())
	row1 = [int(num) for num in input_file.readline().split()]
	row2 = [int(num) for num in input_file.readline().split()]
	sum1 = 0
	sum2 = sum(row2[:-1])
	ans = max(sum1, sum2)
	for j in range(n - 1):
		sum1 += row1[n - 1 - j]
		sum2 -= row2[n - 2 - j]
		ans = min(ans, max(sum1, sum2))
	output_file.write(str(ans) + '\n')


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp = lambda : list(map(int, sys.stdin.readline().rstrip('\r\n').split()))
mod = 10 ** 9 + 7
Mod = 998244353
INF = float('inf')
import math
from bisect import *
from heapq import *
from collections import defaultdict as dd
from collections import OrderedDict as odict
from collections import Counter as cc
from collections import deque
from itertools import groupby
sys.setrecursionlimit(20 * 20 * 20 * 20 + 10)

def solve():
	n = takein()
	mat = [[-1] * n for i in range(2)]
	for i in range(2):
		arr = takeiar()
		index = 0
		for j in arr:
			mat[i][index] = j
			index += 1
	if n == 1:
		print(0)
		return
	if n == 2:
		print(min(mat[0][1], mat[1][0]))
		return
	sum = 0
	for i in range(1, n):
		sum += mat[0][i]
	ans = sum
	temp = 0
	for i in range(1, n - 1):
		temp += mat[1][i - 1]
		sum -= mat[0][i]
		temp1 = max(temp, sum)
		ans = min(temp1, ans)
	ans = min(ans, temp + mat[1][i])
	print(ans)
	return

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = takein()
	for tt in range(1, t + 1):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def takein():
	return int(sys.stdin.readline().rstrip('\r\n'))

def takesr():
	return sys.stdin.readline().rstrip('\r\n')

def takeiar():
	return list(map(int, sys.stdin.readline().rstrip('\r\n').split()))

def takesar():
	return list(map(str, sys.stdin.readline().rstrip('\r\n').split()))

def takeivr():
	return map(int, sys.stdin.readline().rstrip('\r\n').split())

def takesvr():
	return map(str, sys.stdin.readline().rstrip('\r\n').split())

def ispalindrome(s):
	return s == s[::-1]

def invert(bit_s):
	temp = int(bit_s, 2)
	inverse_s = temp ^ 2 ** (len(bit_s) + 1) - 1
	rslt = bin(inverse_s)[3:]
	return str(rslt)

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def power_two(x):
	return x and (not x & x - 1)

def ceil(a, b):
	return -(-a // b)

def seive(n):
	a = [1]
	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 = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	return a

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def binary_search(li, val):
	ans = -1
	lb = 0
	ub = len(li) - 1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


def main(n, a, b) -> int:
	pref_a = [0]
	pref_b = [0]
	suf_a = [0]
	suf_b = [0]
	for i in range(n):
		pref_a.append(pref_a[-1] + a[i])
		pref_b.append(pref_b[-1] + b[i])
	pref_a.append(pref_a[-1])
	pref_b.append(pref_b[-1])
	for i in range(n - 1, -1, -1):
		suf_a.append(suf_a[-1] + a[i])
		suf_b.append(suf_b[-1] + b[i])
	suf_a.append(suf_a[-1])
	suf_b.append(suf_b[-1])
	suf_a.reverse()
	suf_b.reverse()
	bob_score = float('inf')
	for i in range(1, n + 1):
		_alice_score = pref_a[i] + suf_b[i]
		_bob_score = max(pref_b[i - 1], suf_a[i + 1])
		if bob_score > _bob_score:
			bob_score = _bob_score
	return bob_score
t = int(input())
ans = []
for i in range(t):
	m = int(input())
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	ans.append(main(m, a, b))
for i in ans:
	print(i)


import sys
for _ in range(int(input())):
	m = int(input())
	a = []
	a.append([int(i) for i in input().split()])
	a.append([int(i) for i in input().split()])
	for i in range(1, m):
		for j in range(2):
			a[j][i] += a[j][i - 1]
	score = sys.maxsize
	for i in range(m):
		score_i = a[0][m - 1] - a[0][i]
		if i != 0:
			score_i = max(score_i, a[1][i - 1])
		score = min(score, score_i)
	print(score)


for _ in range(int(input())):
	m = int(input())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	s = sum(a1)
	(h, x) = ([], 0)
	for i in range(m):
		s -= a1[i]
		h.append(max(s, x))
		x += a2[i]
	if len(h) == 0:
		print(0)
	else:
		print(min(h))


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

def lcm(a, b):
	return a * b // gcd(a, b)
testcases = 1
testcases = int(input())
for _ in range(testcases):
	m = int(input())
	row1 = [int(x) for x in input().split()]
	row2 = [int(x) for x in input().split()]
	pref = [0]
	suf = [0]
	for i in row2:
		pref.append(pref[-1] + i)
	for i in range(m - 1, -1, -1):
		suf.append(suf[-1] + row1[i])
	mini = 1000000000000000.0
	for i in range(m):
		mini = min(mini, max(pref[i], suf[m - i - 1]))
	print(mini)


n = int(input())
for task in range(n):
	m = int(input())
	s1 = [int(num1) for num1 in input().split()]
	s2 = [int(num2) for num2 in input().split()]
	res = []
	sum1 = sum(s1)
	sum2 = 0
	for i in range(m):
		sum1 -= s1[i]
		res.append(max(sum1, sum2))
		sum2 += s2[i]
	print(min(res))


import heapq, math
from collections import defaultdict, deque
from os import getcwd
from itertools import permutations
import sys, os.path
if os.path.exists('C:/Users/Dhanush/Desktop/cp/input.txt'):
	sys.stdout = open('C:/Users/Dhanush/Desktop/cp/output.txt', 'w')
	sys.stdin = open('C:/Users/Dhanush/Desktop/cp/input.txt', 'r')
input = sys.stdin.readline

def psum(arr, i, j):
	if i > j:
		return 0
	s = arr[j]
	if i - 1 >= 0:
		s -= arr[i - 1]
	return s
tc = int(input())
for _ in range(tc):
	m = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(s1, s2) = (0, 0)
	prea = []
	preb = []
	for i in range(m):
		s1 += a[i]
		s2 += b[i]
		prea.append(s1)
		preb.append(s2)
	ans = float('inf')
	for i in range(1, m - 1):
		c1 = psum(prea, i + 1, m - 1)
		c2 = psum(preb, 0, i - 1)
		cur = max(c1, c2)
		ans = min(ans, cur)
	ans = min(ans, psum(prea, 1, m - 1), psum(preb, 0, m - 2))
	print(ans)


import math

def pn(x, y, m):
	s1 = 0
	s2 = 0
	ans = math.inf
	for i in range(m):
		s1 += x[i]
	for i in range(m):
		s1 -= x[i]
		ans = min(ans, max(s1, s2))
		s2 += y[i]
	return ans
n = int(input())
for i in range(n):
	m = int(input())
	x = list(map(int, input().split()))[:m]
	y = list(map(int, input().split()))[:m]
	print(pn(x, y, m))


from collections import deque
import heapq
from math import sqrt
import operator
from operator import itemgetter
import sys
import copy
inf_var = 0
if inf_var == 1:
	inf = open('input.txt', 'r')
else:
	inf = sys.stdin
input = inf.readline

def read_one_int():
	return int(input().rstrip('\n'))

def read_one_float():
	return float(input().rstrip('\n'))

def read_list_of_ints():
	res = [int(val) for val in input().rstrip('\n').split(' ')]
	return res

def read_str():
	return input().rstrip()

def to_left_diag(i, j):
	return i + j

def to_right_diag(i, j):
	return i - j

class Vertex:

	def __init__(self):
		self.next = {}
		self.terminal = False
		self.cnt = 1

def add_str(trie, cur_str):
	vertices_cnt = 0
	cur_node = trie
	for ch in cur_str:
		if ch in cur_node.next:
			cur_node = cur_node.next[ch]
			cur_node.cnt += 1
		else:
			cur_node.next[ch] = Vertex()
			vertices_cnt += 1
			cur_node = cur_node.next[ch]
	cur_node.terminal = True
	return vertices_cnt

def main():
	tests = read_one_int()
	for _ in range(tests):
		m = read_one_int()
		row_1 = read_list_of_ints()
		row_2 = read_list_of_ints()
		cur_res = 10 ** 10
		for i in range(1, m):
			row_1[i] += row_1[i - 1]
			row_2[i] += row_2[i - 1]
		for i in range(m):
			left_1 = row_1[m - 1] - row_1[i]
			if i > 0:
				left_2 = row_2[i - 1]
			else:
				left_2 = 0
			cur_max = max(left_1, left_2)
			cur_res = min(cur_res, cur_max)
		print(cur_res)
main()


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(n, a, b):
	for i in range(n - 2, -1, -1):
		a[i] += a[i + 1]
	for i in range(1, n):
		b[i] += b[i - 1]
	ans = 0
	for i in range(1, n):
		ans = max(ans, min(a[i], b[i - 1]))
	print(ans)
for _ in range(int(input())):
	n = int(input())
	a = int_arr()
	b = int_arr()
	solve(n, a, b)


for nt in range(int(input())):
	m = int(input())
	a = []
	a.append(list(map(int, input().split())))
	a.append(list(map(int, input().split())))
	if m == 1:
		print(0)
		continue
	prefix = [[0 for i in range(m)] for j in range(2)]
	suffix = [[0 for i in range(m)] for j in range(2)]
	prefix[0][0] = a[0][0]
	prefix[1][0] = a[1][0]
	for i in range(1, m):
		prefix[0][i] = prefix[0][i - 1] + a[0][i]
		prefix[1][i] = prefix[1][i - 1] + a[1][i]
	suffix[0][-1] = a[0][-1]
	suffix[1][-1] = a[1][-1]
	for i in range(m - 2, -1, -1):
		suffix[0][i] = suffix[0][i + 1] + a[0][i]
		suffix[1][i] = suffix[1][i + 1] + a[1][i]
	ans = min(suffix[0][1], prefix[1][-2])
	for i in range(1, m - 1):
		ans = min(ans, max(prefix[1][i - 1], suffix[0][i + 1]))
	print(ans)


from itertools import product
import itertools
import math
import sys
import heapq
from collections import deque
MOD = 1000000000007

def find(parent, i):
	if parent[i] != i:
		parent[i] = find(parent, parent[i])
	return parent[i]

def union(parent, rank, xx, yy):
	x = find(parent, xx)
	y = find(parent, yy)
	if rank[x] > rank[y]:
		parent[y] = x
	elif rank[y] > rank[x]:
		parent[x] = y
	else:
		parent[y] = x
		rank[x] += 1
ans = 0
K = int(sys.stdin.readline().strip())
x = 0
y = 0
for _ in range(K):
	m = int(sys.stdin.readline().strip())
	mat = []
	l = list(map(int, sys.stdin.readline().strip().split()))
	M = sum(l)
	mat.append(l)
	l = list(map(int, sys.stdin.readline().strip().split()))
	M = max(M, sum(l))
	mat.append(l)
	p1 = [0]
	p2 = [0]
	for i in range(m - 1, -1, -1):
		p1.append(p1[-1] + mat[0][i])
	p1.reverse()
	for i in range(m):
		p2.append(p2[-1] + mat[1][i])
	ans = M
	for i in range(m):
		ans = min(ans, max(p1[i + 1], p2[i]))
	print(ans)


___t = int(input())
for t___ in range(___t):
	m = int(input())
	ss = input().split()
	a = [0] * m
	for i in range(m):
		a[i] = int(ss[i])
	ss = input().split()
	b = [0] * m
	bsum = 0
	for i in range(m):
		b[i] = int(ss[i])
		bsum += b[i]
	res = 0
	asum = 0
	for i in range(m - 1):
		asum += a[m - i - 1]
		bsum -= b[m - i - 1]
		res = max(res, min(asum, bsum))
	print(res)


from itertools import accumulate

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

def solve():
	m = int(input())
	a1 = list(accumulate(reversed(readline()), initial=0))
	a2 = list(accumulate(readline(), initial=0))
	print(min((max(a1[i], a2[m - 1 - i]) for i in range(m))))
t = int(input())
for __ in range(t):
	solve()


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections, string, bisect, re, random, queue, itertools, statistics, math
from collections import *
from bisect import *
from string import *
from itertools import *
from statistics import *
from math import *
from re import *
from queue import *

class Stack:

	def __init__(self):
		self.items = []

	def push(self, item):
		self.items.append(item)

	def pop(self):
		return self.items.pop()

	def empty(self):
		return self.items == []

	def size(self):
		return len(self.items)

	def at(self, idx):
		try:
			return self.items[idx]
		except:
			return -1

class priority_queue(object):

	def __init__(self):
		self.queue = []

	def __str__(self):
		return ' '.join([str(i) for i in self.queue])

	def empty(self):
		return len(self.queue) == 0

	def push(self, data):
		self.queue.append(data)

	def pop(self):
		try:
			max = 0
			for i in range(len(self.queue)):
				if self.queue[i] > self.queue[max]:
					max = i
			item = self.queue[max]
			del self.queue[max]
			return item
		except IndexError:
			print()
			exit()
mod = int(1000000000.0 + 7)
imax = float('inf')
imin = float('-inf')
true = True
false = False
N = int(100000.0)
none = None
inp = lambda : input()
I = lambda : int(inp())
M = lambda : map(int, inp().split())
MS = lambda : map(str, inp().split())
S = lambda : list(MS())
L = lambda : list(M())

def IO():
	try:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('uttar.txt', 'w')
	except:
		pass
IO()

class helper:

	def first(self, arr):
		return arr[0]

	def second(self, arr):
		return arr[1]

	def is_sorted(self, arr):
		return arr == sorted(arr)

def kabraji_ka_totka():
	m = I()
	mat = [L() for i in range(2)]
	if m == 1:
		print(0)
		return
	max_range = sum(mat[0]) - mat[0][0]
	res = max_range
	y_axis = 0
	for i in range(1, m):
		y_axis += mat[1][i - 1]
		max_range -= mat[0][i]
		res = min(res, max(max_range, y_axis))
	print(max(res, 0))
case = 1
case = I()
for i in range(case):
	kabraji_ka_totka()


import sys
input = sys.stdin.readline
for test in range(int(input().strip())):
	n = int(input().strip())
	ls1 = list(map(int, input().strip().split()))
	lis2 = list(map(int, input().strip().split()))
	nlis = []
	c = d = 0
	for i in range(n):
		c += ls1[i]
		ls1[i] = c
		d += lis2[i]
		nlis.append(d)
	ans = ls1[-1] + nlis[-1]
	for i in range(n):
		ans = min(ans, max(ls1[-1] - ls1[i], nlis[i] - lis2[i]))
	print(ans)


t = int(input())
while t:
	t = t - 1
	m = int(input())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	y = sum(a1)
	x = 0
	ans = 10000000000000
	for i in range(m):
		y -= a1[i]
		ans = min(ans, max(x, y))
		x += a2[i]
	print(ans)


def solve(n, a, b):
	sa = sum(a)
	sb = sum(b)
	ca = 0
	cb = 0
	for i in range(n):
		if i == 0:
			x = sa - a[i]
			ca = a[0]
			cb = b[0]
		else:
			y = max(sa - ca - a[i], cb)
			x = min(x, y)
			ca += a[i]
			cb += b[i]
	return x
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(solve(n, a, b))


for _ in range(int(input())):
	m = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	sum1 = sum(l1) - l1[0]
	sum2 = 0
	res1 = sum(l1) - l1[0]
	res2 = 0
	for i in range(1, m):
		sum1 -= l1[i]
		sum2 += l2[i - 1]
		if max(sum1, sum2) < max(res1, res2):
			res1 = sum1
			res2 = sum2
	print(max(res1, res2))


from itertools import accumulate
t = int(input())
for _ in range(t):
	m = int(input())
	a_1 = list(accumulate([int(i) for i in input().split()]))
	a_2 = list(accumulate([int(i) for i in input().split()]))
	print(min([max(a_2[i - 1] if i else 0, a_1[m - 1] - a_1[i]) for i in range(m)]) if m > 1 else 0)


for i in range(int(input())):
	m = int(input())
	arr = []
	arr.append(list(map(int, input().split())))
	arr.append(list(map(int, input().split())))
	ans = 100000000000.0
	s1 = sum(arr[0])
	s2 = 0
	if m == 1:
		print(0)
		continue
	for j in range(m):
		s1 -= arr[0][j]
		ans = min(ans, max(s1, s2))
		s2 += arr[1][j]
	print(ans)


import sys
from math import factorial, gcd
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify, nlargest, nsmallest
from itertools import groupby
from copy import deepcopy
MOD = 10 ** 9 + 7
INF = float('inf')
rl = lambda : list(map(int, sys.stdin.readline().split()))
rs = lambda : sys.stdin.readline().strip()
for _ in range(int(input())):
	m = int(input())
	matrix = [rl() for _ in range(2)]
	if m == 1:
		print(0)
		continue
	(psum1, psum2) = ([0], [0])
	for j in range(m - 1, -1, -1):
		psum1.append(psum1[-1] + matrix[0][j])
	for j in range(m):
		psum2.append(psum2[-1] + matrix[1][j])
	psum1.reverse()
	psum1.append(0)
	psum2.append(0)
	res = INF
	for i in range(1, m + 1):
		val = max(psum1[i], psum2[i - 1])
		res = min(res, val)
	print(res)


import sys
testcases = int(input())
while testcases > 0:
	n = int(input())
	row1 = list(map(int, sys.stdin.readline().split()))
	row2 = list(map(int, sys.stdin.readline().split()))
	s1 = sum(row1) - row1[0]
	s2 = 0
	a = s1
	b = 0
	for i in range(1, n):
		s2 += row2[i - 1]
		s1 -= row1[i]
		b = max(s1, s2)
		a = min(b, a)
	print(a)
	testcases -= 1


for t in range(int(input())):
	m = int(input())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	ans = 10 ** 10
	sm1 = sum(a1)
	sm2 = 0
	for i in range(m):
		sm1 -= a1[i]
		ans = min(ans, max(sm2, sm1))
		sm2 += a2[i]
	print(ans)


for _ in range(int(input())):
	n = int(input())
	s1 = [int(x) for x in input().split()]
	s2 = [int(x) for x in input().split()]
	pr1 = [0]
	pr2 = [0]
	for i in range(n):
		pr1.append(pr1[-1] + s1[i])
		pr2.append(pr2[-1] + s2[i])
	best = pr2[-1] - s2[-1]
	for i in range(n):
		best = min(best, max(pr1[-1] - pr1[i + 1], pr2[i]))
	print(best)


R = lambda : map(int, input().split())
(t,) = R()
while t:
	t -= 1
	R()
	a = (*R(),)
	u = sum(a)
	v = 0
	r = 1000000000.0
	for (x, y) in zip(a, R()):
		u -= x
		r = min(r, max(u, v))
		v += y
	print(r)


from itertools import accumulate
for _ in range(int(input())):
	m = int(input())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	c1 = list(accumulate([0] + a1[::-1]))
	c2 = list(accumulate([0] + a2))
	x = float('inf')
	for i in range(m):
		s = max(c2[i], c1[-i - 2])
		if s < x:
			x = s
	print(x)


def solve(m, x):
	pcl = [0] * m
	for i in range(1, m):
		pcl[i] = pcl[i - 1] + x[1][i - 1]
	pcu = [0] * m
	for i in range(m - 2, -1, -1):
		pcu[i] = pcu[i + 1] + x[0][i + 1]
	r = 2 ** 65
	for i in range(m):
		r = min(r, max(pcl[i], pcu[i]))
	print(r)
t = int(input())
for i in range(t):
	m = int(input())
	x = [[int(j) for j in input().split()] for _ in '12']
	solve(m, x)


import sys
input = sys.stdin.readline
from pprint import pprint
INF = 1 << 63

def do():
	import itertools

	class CumSum1D:

		def __init__(self):
			pass

		def load(self, a):
			self.sdat = list(itertools.accumulate(itertools.chain([0], a)))

		def query(self, l, r):
			return self.sdat[r] - self.sdat[l]
	n = int(input())
	dat1 = list(map(int, input().split()))
	dat2 = list(map(int, input().split()))
	s1 = CumSum1D()
	s2 = CumSum1D()
	s1.load(dat1)
	s2.load(dat2)
	res = INF
	for i in range(n):
		score = max(s1.query(i + 1, n), s2.query(0, i))
		res = min(res, score)
	print(res)
q = int(input())
for _ in range(q):
	do()


from sys import stdin, stdout

def INPUT():
	return list((int(i) for i in stdin.readline().split()))

def inp():
	return stdin.readline()

def out(x):
	return stdout.write(x)
import math
INT_MAX = 10 ** 13
from bisect import bisect_left
import sys
MOD = 10 ** 9 + 7
inf = MOD ** 2
for _ in range(int(input())):
	n = int(input())
	A = INPUT()
	B = INPUT()
	if n == 1:
		print(0)
		continue
	s = sum(A) + sum(B)
	score = 0
	sumA = [0] * n
	sumB = [0] * n
	sumB[0] = B[0]
	sumA[0] = A[0]
	ans = inf
	for i in range(1, n):
		sumA[i] = sumA[i - 1] + A[i]
		sumB[i] = sumB[i - 1] + B[i]
	for i in range(n):
		if i > 0:
			k = max(sumA[-1] - sumA[i], sumB[i - 1])
		else:
			k = sumA[-1] - sumA[0]
		ans = min(ans, k)
	print(ans)


def rows_of_coins(m: int, rows: list):
	if m == 1:
		return 0
	if m == 2:
		return min(rows[0][1], rows[1][0])
	arr = [[0] * m, [0] * m]
	arr[1][0] = rows[1][0]
	arr[0][m - 1] = rows[0][m - 1]
	for i in range(1, m - 1):
		arr[1][i] = arr[1][i - 1] + rows[1][i]
		arr[0][m - 1 - i] = arr[0][m - i] + rows[0][m - 1 - i]
	min_coins = 10 ** 4 * m
	for i in range(2, m):
		cur_min = max(arr[0][i], arr[1][i - 2])
		if cur_min < min_coins:
			min_coins = cur_min
	return min(min_coins, arr[0][1], arr[1][-2])
t = int(input())
for i in range(t):
	m = int(input())
	rows = [list(map(int, input().split(' '))), list(map(int, input().split(' ')))]
	print(rows_of_coins(m, rows))


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


def get_t(ot):
	n = len(ot[0])
	tt = [0] * n
	tb = [0] * n
	st = 0
	sb = 0
	t = [tt, tb]
	for i in range(n - 1, -1, -1):
		sb += ot[1][i]
		st = ot[0][i] + max(sb, st)
		t[0][i] = st
		t[1][i] = sb
	return t

def sol(ot):
	n = len(ot[0])
	ax = 0
	ay = 0
	opt = -1
	opt_id = -1
	t = [0] * n
	st = 0
	b = [0] * n
	sb = 0
	for i in range(0, n):
		st += ot[0][-i - 1]
		sb += ot[1][i]
		t[-i - 1] = st
		b[i] = sb
	for i in range(n):
		cur = 0
		if i < n - 1:
			cur = t[i + 1]
		if i > 0:
			cur = max(b[i - 1], cur)
		if cur < opt or opt == -1:
			opt = cur
			opt_id = i
	print(opt)
for _ in range(int(input())):
	n = int(input())
	t1 = list(map(int, input().split()))
	t2 = list(map(int, input().split()))
	ot = [t1, t2]
	sol(ot)


import sys
import math
mod = 10 ** 9 + 7
LI = lambda : [int(k) for k in input().split()]
input = lambda : sys.stdin.readline().rstrip()
IN = lambda : int(input())
S = lambda : input()
r = range
for t in r(IN()):
	m = IN()
	arr = []
	top = LI()
	bottom = LI()
	if m == 1:
		print(0)
		continue
	presum = 0
	for i in reversed(range(m)):
		presum += top[i]
		top[i] = presum
	presum = 0
	for i in range(m):
		presum += bottom[i]
		bottom[i] = presum
	ans = min(top[1], bottom[m - 2])
	for i in range(1, m - 1):
		ans = min(ans, max(top[i + 1], bottom[i - 1]))
	print(ans)


import sys
from collections import Counter
import math
import bisect
import heapq
from itertools import combinations
from itertools import accumulate
num_cases = int(sys.stdin.readline().strip())
for case in range(1, num_cases + 1):
	M = int(sys.stdin.readline().strip())
	one_row = list(map(int, sys.stdin.readline().split()))
	two_row = list(map(int, sys.stdin.readline().split()))
	acc_one = list(accumulate(one_row))
	acc_two = list(accumulate(two_row))
	result = float('inf')
	for down in range(M):
		if down == 0:
			value = acc_one[M - 1] - acc_one[0]
		elif down == M - 1:
			value = acc_two[M - 2]
		else:
			first = acc_one[M - 1] - acc_one[down]
			second = acc_two[down - 1]
			value = max(first, second)
		result = min(result, value)
	print(result)


import sys
import math
import heapq
from collections import defaultdict as dd
from collections import OrderedDict as od
from collections import deque
from itertools import permutations as pp
from itertools import combinations as cc
from sys import stdin
from functools import cmp_to_key
from functools import lru_cache
from bisect import bisect_left as bs_l
from bisect import bisect_right as bs_r
input = sys.stdin.readline
mod = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 5)
T = int(input())
for _ in range(T):
	n = int(input())
	ans = 10 ** 9
	mat = []
	for i in range(2):
		mat.append(list(map(int, input().split())))
	(x, y) = (0, 0)
	for i in range(2):
		for j in range(n):
			if i == 0:
				x += mat[i][j]
	for i in range(n):
		x -= mat[0][i]
		ans = min(ans, max(x, y))
		y += mat[1][i]
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	tsl = sum(l)
	res = 10 ** 10
	for i in range(n):
		tsl = tsl - l[i]
		if i == 0:
			ans2 = 0
		else:
			ans2 += l1[i - 1]
		ans = max(tsl, ans2)
		res = min(res, ans)
	print(res)


import sys
input = sys.stdin.readline
t = []
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	(res, u, d, up, do) = (float('inf'), 0, 0, [], [])
	for i in range(n):
		u += a[i]
		d += b[i]
		up += [u]
		do += [d]
	for i in range(n):
		p = max(u - up[i], do[i - 1] * (i != 0))
		res = min(res, p)
	t += [res]
for k in t:
	print(k)


import sys
input = sys.stdin
output = sys.stdout
N = int(input.readline().strip())
for x in range(N):
	OB = 999999999999999999999999999999999999999999
	C = int(input.readline().strip())
	row1 = [int(num) for num in input.readline().split()]
	row2 = [int(num) for num in input.readline().split()]
	top = 0
	bottom = 0
	for i in range(C):
		top += row1[i]
	for i in range(C):
		top -= row1[i]
		if i > 0:
			bottom += row2[i - 1]
		if top >= bottom:
			if top < OB:
				OB = top
		elif bottom < OB:
			OB = bottom
	output.write('%d\n' % OB)


import sys, math
inf = math.inf
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
a = int(input())
for _ in range(a):
	m = int(input())
	l = [list(map(int, input().split())) for i in range(2)]
	if m == 1:
		print(0)
	else:
		y1 = [0]
		y2 = [0]
		ch = 0
		for i in range(m):
			y1.append(l[0][i] + y1[i])
			y2.append(l[1][i] + y2[i])
		for i in range(m):
			if i == m - 1:
				ch = i
				break
			if y2[i + 1] > y1[m] - y1[i + 1]:
				ch = i
				break
		print(max(y1[m] - y1[ch + 1], y2[ch]))


import sys
input = sys.stdin.readline
t = []
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	(res, u, d, up, do) = (float('inf'), 0, 0, [], [0])
	for i in range(n):
		u += a[i]
		d += b[i]
		up += [u]
		do += [d]
	for i in range(n):
		p1 = u - up[i]
		p2 = do[i]
		if p1 > p2:
			if p1 < res:
				res = p1
		elif p2 < res:
			res = p2
	t += [res]
for k in t:
	print(k)


for _ in range(int(input())):
	m = int(input())
	liste1 = list(map(int, input().split()))
	liste2 = list(map(int, input().split()))
	list1 = []
	list2 = []
	liste1.reverse()
	last = 0
	last2 = 0
	listefinale = []
	for i in range(0, m - 1):
		list1.append(liste1[i] + last)
		list2.append(liste2[i] + last2)
		last = last + liste1[i]
		last2 = last2 + liste2[i]
	list1.insert(0, 0)
	list2.reverse()
	list2.append(0)
	for (elmt, elmtt) in zip(list1, list2):
		if elmt < elmtt:
			listefinale.append(elmtt)
		else:
			listefinale.append(elmt)
	listefinale.sort()
	print(listefinale[0])


for _ in range(int(input())):
	m = int(input())
	up = list(map(int, input().split()))
	down = list(map(int, input().split()))
	pref_up = [0]
	pref_down = [0]
	count = 10 ** 10
	for i in range(m):
		pref_up.append(pref_up[-1] + up[i])
		pref_down.append(pref_down[-1] + down[i])
	for i in range(m):
		if max(pref_up[m] - pref_up[i + 1], pref_down[i]) < count:
			count = max(pref_up[m] - pref_up[i + 1], pref_down[i])
	print(count)


t = int(input())
while t > 0:
	(n, m) = (2, int(input()))
	A = [0] * n
	for i in range(n):
		a1 = list(map(int, input().split()))
		A[i] = a1
	p = [0] * (m + 1)
	for i in range(1, m + 1):
		p[i] = p[i - 1] + A[0][i - 1]
	p1 = [0] * (m + 1)
	for i in range(1, m + 1):
		p1[i] = p1[i - 1] + A[1][i - 1]
	ans = []
	for i in range(m):
		x = p1[i] - p1[0]
		y = p[-1] - p[i + 1]
		ans.append(max(x, y))
	print(min(ans))
	t -= 1


t = int(input())
results = [None] * t
for l in range(t):
	m = int(input())
	row_1 = [int(x) for x in input().split()]
	row_2 = [int(x) for x in input().split()]
	lowest_score = sum(row_1) + sum(row_2)
	score1 = sum(row_1)
	score2 = 0
	for i in range(m):
		score1 -= row_1[i]
		score = max(score1, score2)
		if score < lowest_score:
			lowest_score = score
		score2 += row_2[i]
	results[l] = lowest_score
[print(x) for x in results]


test = int(input())
while test:
	test -= 1
	n = int(input())
	mat1 = list(map(int, input().split()))
	mat2 = list(map(int, input().split()))
	dp1 = [0 for i in range(n)]
	dp2 = [0 for i in range(n)]
	alice = sum(mat1)
	for i in range(n):
		dp1[i] = dp1[i - 1] + mat1[i]
	for j in range(n):
		dp2[j] = dp2[j - 1] + mat2[j]
	money = 0
	score = 10 ** 11
	for i in range(n):
		money = max((dp2[i] - mat2[i]) % (10 ** 9 + 7), (alice - dp1[i]) % (10 ** 9 + 7))
		if score > money:
			score = money % (10 ** 9 + 7)
	print(score % (10 ** 9 + 7))


from math import *
from collections import defaultdict as dt
from sys import stdin
inp = lambda : stdin.readline().strip()
I = lambda : int(inp())
M = lambda : map(int, inp().split())
L = lambda : list(M())
mod = 1000000007
inf = 100000000000000000000
ss = 'abcdefghijklmnopqrstuvwxyz'

def solve():
	n = I()
	a = L()
	b = L()
	if n == 1:
		print(0)
		return
	c = dt(int)
	c[n - 1] = a[-1]
	d = dt(int)
	d[0] = b[0]
	e = inf
	for i in range(n - 2, 0, -1):
		c[i] = a[i] + c[i + 1]
	for i in range(1, n - 1):
		d[i] = b[i] + d[i - 1]
	for i in range(n):
		e = min(e, max(c[i + 1], d[i - 1]))
	print(e)
tt = 1
tt = I()
for _ in range(tt):
	solve()


import math
import sys
inp = int(input())
for _ in range(inp):
	m = 2
	n = int(input())
	mat = []
	row1 = 0
	row2 = 0
	for i in range(m):
		s = list(map(int, input().split(' ')))
		mat.append(s)
	res = float('inf')
	for i in range(n):
		row1 += mat[0][i]
	for i in range(n):
		row1 -= mat[0][i]
		res = min(res, max(row1, row2))
		row2 += mat[1][i]
	print(res)


import sys
input = sys.stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())

def solve():
	n = I()
	a = L()
	b = L()
	suma = sum(a)
	sumb = sum(b)
	for i in range(1, n):
		a[i] = a[i - 1] + a[i]
	for i in range(n - 2, -1, -1):
		b[i] = b[i] + b[i + 1]
	ans = 0
	l = []
	for i in range(n):
		l.append(max(suma - a[i], sumb - b[i]))
	l.sort()
	print(l[0])
for _ in range(I()):
	solve()


import collections as cc
import bisect as bi
import heapq as hp
import math as mt
import itertools as it
import sys
import io, os
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n,) = I()
	ar = [I() for i in range(2)]
	suff = ar[0].copy()
	for i in range(n - 2, -1, -1):
		suff[i] += suff[i + 1]
	pref = ar[1].copy()
	for i in range(1, n):
		pref[i] += pref[i - 1]
	temp = []
	suff = suff[1:] + [0]
	pref = [0] + pref
	for i in range(n):
		temp.append(max(suff[i], pref[i]))
	print(min(temp))


import math
import sys
for _ in range(int(input())):
	m = int(input())
	c1 = list(map(int, input().split()))
	c2 = list(map(int, input().split()))
	min_ = sys.maxsize
	temp = 0
	result = 0
	sum1 = sum(c1)
	sum2 = 0
	for i in range(m):
		if i == 0:
			sum2 = 0
		else:
			sum2 += c2[i - 1]
		sum1 -= c1[i]
		score_bob = max(sum1, sum2)
		if score_bob < min_:
			min_ = score_bob
			result = score_bob
			temp = i
	print(result)


test = int(input())
for t in range(test):
	m = int(input())
	a = []
	a.append(list(map(int, input().split())))
	a.append(list(map(int, input().split())))
	if m == 1:
		print(0)
		continue
	for i in range(1, m):
		a[0][i] += a[0][i - 1]
	for i in range(m - 2, -1, -1):
		a[1][i] += a[1][i + 1]
	bob = min(a[0][m - 1] - a[0][0], a[1][0] - a[1][m - 1])
	for i in range(1, m - 1):
		bob = min(bob, max(a[0][m - 1] - a[0][i], a[1][0] - a[1][i]))
	print(bob)


def main():
	for _ in range(int(input())):
		m = int(input())
		L1 = [int(l) for l in input().split()]
		L2 = [int(l) for l in input().split()]
		pr1 = [0]
		pr2 = [0]
		sm = 0
		for i in range(m):
			sm += L1[i] + L2[i]
			pr1.append(pr1[-1] + L1[i])
			pr2.append(pr2[-1] + L2[i])
		r2 = 10000000000.0
		for i in range(1, m):
			r2 = min(r2, max(pr2[i - 1] - pr2[0], pr1[-1] - pr1[i]))
		r2 = min(r2, pr2[-2])
		print(r2)
main()


def coin_rows(matrix):
	n = len(matrix[0])
	if n == 1:
		return 0
	sums1 = [0] * n
	sums1[0] = matrix[0][0]
	for i in range(1, n):
		sums1[i] = matrix[0][i] + sums1[i - 1]
	sums2 = [0] * n
	sums2[0] = matrix[1][0]
	for i in range(1, n):
		sums2[i] = matrix[1][i] + sums2[i - 1]
	score = sums1[n - 1] - sums1[0]
	for i in range(1, n):
		score = min(max(sums1[n - 1] - sums1[i], sums2[i - 1]), score)
	return score
T = int(input())
for t in range(T):
	n = int(input())
	matrix = []
	for i in range(2):
		row = list(map(int, input().split()))
		matrix.append(row)
	print(coin_rows(matrix))


def score(m, l1, l2):
	mat = [l1, l2]
	sum1 = sum(l1)
	s4 = sum(l2)
	sum2 = 0
	sum1 -= l1[0]
	sum2 += mat[1][0]
	for i in range(1, m):
		if sum2 > sum1:
			s4 -= mat[1][i - 1]
		else:
			sum1 -= mat[0][i]
			sum2 += mat[1][i]
	s4 -= mat[1][m - 1]
	return max(sum1, s4)
for i in range(int(input())):
	m = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	print(score(m, l1, l2))


for _ in range(int(input())):
	m = int(input())
	ar = list(map(int, input().split()))
	br = list(map(int, input().split()))
	r0 = sum(ar)
	r1 = sum(br)
	su = 0
	for i in range(m):
		su += ar[i]
		ar[i] = su
	su = 0
	for i in range(m - 1, -1, -1):
		su += br[i]
		br[i] = su
	ans = []
	for i in range(m):
		x1 = r0 - ar[i]
		x2 = r1 - br[i]
		ans.append(max(x1, x2))
	print(min(ans))


import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	m = int(input())
	a = [*map(int, input().split())]
	b = [*map(int, input().split())]
	s = sum(a) - a[0]
	ans = s
	x = 0
	for i in range(1, m):
		x += b[i - 1]
		s -= a[i]
		p = max(x, s)
		ans = min(ans, p)
	print(ans)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	game_up = list(map(int, input().split()))
	game_down = list(map(int, input().split()))
	sum_up = sum(game_up)
	sum_down = 0
	bob_min = 10 ** 10 + 2
	for i in range(n):
		sum_up -= game_up[i]
		bob_min = min(bob_min, max(sum_up, sum_down))
		sum_down += game_down[i]
	print(bob_min)


t = int(input())
for _ in range(t):
	f = int(input())
	if f == 1:
		a = int(input())
		b = int(input())
		print('0')
	else:
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		sa = 0
		sb = 0
		sua = []
		sub = []
		for i in range(f):
			sa = sa + a[f - 1 - i]
			sb = sb + b[i]
			sub.append(sb)
			sua.insert(0, sa)
		sua.append(0)
		sub.insert(0, 0)
		flag = 0
		for i in range(f + 1):
			if sua[i] <= sub[i]:
				break
		k = i
		if i == 0:
			print(sua[1])
		elif i == f:
			print(sub[-2])
		else:
			print(max(min(sua[k], sub[k]), sub[k - 1]))


for ii in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(u, d, co) = (0, sum(a), 10 ** 9)
	for jj in range(n):
		d -= a[jj]
		co = min(co, max(u, d))
		u += b[jj]
	print(co)


import sys
from sys import stdin, stdout
from math import ceil, floor, sqrt, log, log2, log10
from collections import Counter
int_max = float('inf')
int_min = -float('inf')
ANS = []
input = stdin.readline

def solve():
	pass
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	if n == 1:
		print(0)
		continue
	suff = [0]
	for i in range(n - 1, -1, -1):
		suff.append(suff[-1] + arr[i])
	pref = [0]
	for i in range(n):
		pref.append(pref[-1] + brr[i])
	ans = int_max
	i = 0
	j = n - 1
	while i < n:
		ans = min(ans, max(suff[i], pref[j]))
		i += 1
		j -= 1
	print(ans)
print('\n'.join(ANS))


T = int(input())
for _ in range(T):
	m = int(input())
	coins = []
	coins.append(list(map(int, input().split())))
	coins.append(list(map(int, input().split())))
	bob = float('inf')
	sumTop = sum(coins[0]) - coins[0][0]
	sumBot = 0
	bob = min(max(sumTop, sumBot), bob)
	for i in range(1, m):
		sumTop -= coins[0][i]
		sumBot += coins[1][i - 1]
		bob = min(max(sumTop, sumBot), bob)
	print(0 if m == 1 else bob)


t = int(input())
for case in range(t):
	m = int(input())
	a = []
	b = []
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pfa = [0]
	pfb = [0]
	for x in a:
		pfa.append(x + pfa[-1])
	for x in b:
		pfb.append(x + pfb[-1])
	best = 100000000000
	for i in range(1, m + 1):
		best = min(best, max(pfb[i - 1], pfa[-1] - pfa[i]))
	print(best)


for _ in range(int(input())):
	m = int(input())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	(ac1, ac2) = (0, 0)
	(x, y) = (0, m - 1)
	while x != y:
		if ac1 + a2[x] <= ac2 + a1[y]:
			ac1 += a2[x]
			x += 1
		else:
			ac2 += a1[y]
			y -= 1
	print(max(ac1, ac2))


t = int(input())
for _ in range(t):
	m = int(input())
	first = list(map(int, input().split()))
	second = list(map(int, input().split()))
	first_sum = sum(first)
	left_abandoned = 0
	right_abandoned = first_sum - first[0]
	alice_best = right_abandoned
	i = 0
	while True:
		bob_best = max(left_abandoned, right_abandoned)
		alice_best = min(alice_best, bob_best)
		if i >= len(first) - 1:
			break
		left_abandoned += second[i]
		right_abandoned -= first[i + 1]
		i += 1
	print(alice_best)


t = int(input())
for _ in range(t):
	m = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	k1 = l1[:]
	k2 = l2[:]
	mi = 100000000000.0
	if m == 1:
		print(0)
	elif m == 2:
		print(min(l1[1], l2[0]))
	else:
		for i in range(1, m):
			k2[i] += k2[i - 1]
		for i in range(m - 2, -1, -1):
			k1[i] += k1[i + 1]
		for i in range(1, m - 1):
			mi = min(mi, max(k1[i + 1], k2[i - 1]))
		mi = min(mi, k1[1])
		mi = min(mi, k2[m - 2])
		print(mi)


t = int(input())
for tc in range(t):
	n = int(input())
	a = []
	for i in range(2):
		b = list(map(int, input().split()))
		a.append(b)
	for i in range(2):
		for j in range(1, n):
			if i == 0:
				a[i][j] = a[i][j] + a[i][j - 1]
			else:
				a[i][j] = a[i][j] + a[i][j - 1]
	best = float('inf')
	for j in range(n):
		if j == 0:
			bob = a[0][-1] - a[0][0]
		elif j == n - 1:
			bob = a[1][j - 1]
		else:
			bob = max(a[0][-1] - a[0][j], a[1][j - 1])
		if best > bob:
			best = bob
	print(best)


import sys
from collections import Counter

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))
sys.setrecursionlimit(20000)
T = int(input())
for _ in range(T):
	m = int(input())
	A1 = get_ints()
	A2 = get_ints()
	A1_sum = sum(A1) - A1[0]
	A2_sum = 0
	min_score = max(A1_sum, A2_sum)
	for i in range(1, m):
		A1_sum -= A1[i]
		A2_sum += A2[i - 1]
		score = max(A1_sum, A2_sum)
		if score < min_score:
			min_score = score
	print(min_score)


import math

def solve():
	m = int(input())
	mat = []
	for i in range(2):
		mat.append(list(map(int, input().split())))
	prefix1 = [0 for i in range(m)]
	prefix2 = [0 for j in range(m)]
	row1 = mat[0][0]
	prefix1[0] = mat[0][0]
	row2 = mat[1][0]
	prefix2[0] = mat[1][0]
	for i in range(1, m):
		prefix1[i] = prefix1[i - 1] + mat[0][i]
		prefix2[i] = prefix2[i - 1] + mat[1][i]
		row1 += mat[0][i]
		row2 += mat[1][i]
	ans = 10 ** 15
	for i in range(m):
		temp1 = 0
		if i != 0:
			temp1 = prefix2[i - 1]
		temp2 = row1 - prefix1[i]
		ans = min(ans, max(temp1, temp2))
	return ans
t = int(input())
for i in range(t):
	print(solve())


t = int(input())

def solve():
	m = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	if m == 1:
		print(0)
		return
	ps1 = [arr1[0]]
	for i in range(1, m):
		ps1.append(ps1[-1] + arr1[i])
	ps2 = [0] * m
	ps2[-1] = arr2[-1]
	for i in reversed(range(m - 1)):
		ps2[i] = ps2[i + 1] + arr2[i]
	ans = []
	for i in range(m):
		bob = []
		if i < m - 1:
			bob.append(ps1[-1] - ps1[i])
		if i > 0:
			bob.append(ps2[0] - ps2[i])
		ans.append(max(bob))
	print(min(ans))
for i in range(t):
	solve()


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')
from collections import Counter, defaultdict
import math
import heapq
import bisect

def nck(n, k):
	res = 1
	for i in range(1, k + 1):
		res = res * (n - i + 1) // i
	return res
for _ in range(int(input())):
	n = int(input())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	for i in range(1, n):
		a2[i] += a2[i - 1]
	for i in range(1, n):
		a1[i] += a1[i - 1]
	a = 0
	b = 10 ** 20
	for i in range(n):
		s2 = a1[i]
		if i == 0:
			s2 += a2[-1]
		else:
			s2 += a2[-1] - a2[i - 1]
		vv = 0
		v1 = 0
		if i > 0:
			v1 += a2[i - 1]
		vv += a1[-1] - a1[i]
		b = min(b, max(vv, v1))
	print(b)


for i in range(int(input())):
	m = int(input())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	top = sum(a1) - a1[0]
	bot = 0
	ans = 999999999999
	for i in range(m - 1):
		ans = min(ans, max(top, bot))
		bot += a2[i]
		top -= a1[i + 1]
	ans = min(ans, bot)
	print(ans)


from itertools import accumulate

def solve():
	m = int(input())
	a1 = [int(i) for i in input().split()]
	a2 = [int(i) for i in input().split()]
	acc1 = list(accumulate(a1))
	acc2 = list(accumulate(a2))
	ans = 1 << 32
	for i in range(m):
		res1 = 0
		res2 = 0
		if i > 0:
			res2 = acc2[i - 1]
		if i < m - 1:
			res1 = acc1[m - 1] - acc1[i]
		ans = min(ans, max(res1, res2))
	return ans
t = int(input())
for ind in range(t):
	print(solve())


import sys
input = sys.stdin.readline
t = int(input())
for test in range(t):
	m = int(input())
	rad1 = list(map(int, input().split()))
	rad2 = list(map(int, input().split()))
	steps1 = m - 1
	steps2 = 0
	coins1 = 0
	coins2 = 0
	while steps1 != steps2:
		if coins1 + rad1[steps1] < coins2 + rad2[steps2]:
			coins1 = coins1 + rad1[steps1]
			steps1 = steps1 - 1
		else:
			coins2 = coins2 + rad2[steps2]
			steps2 = steps2 + 1
	print(max(coins1, coins2))


def solve():
	t = int(input())
	for _ in range(t):
		m = int(input())
		matrix = [list(map(int, input().split())), list(map(int, input().split()))]
		score = [sum(matrix[0]) - matrix[0][0]]
		(up, down) = (score[0], 0)
		for i in range(1, m):
			up -= matrix[0][i]
			down += matrix[1][i - 1]
			score.append(max(up, down))
		print(min(score))
solve()


from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

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

def si():
	return input().rstrip()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

def ceil(a, b):
	return (a + b - 1) // b

def solve():
	for _ in range(1, ii() + 1):
		m = ii()
		a = li()
		b = li()
		pre = [[0, 0] for i in range(m)]
		for i in range(m):
			if i:
				pre[i][0] += pre[i - 1][0]
			pre[i][0] += a[i]
		for i in range(m):
			if i:
				pre[i][1] += pre[i - 1][1]
			pre[i][1] += b[i]
		mnx = inf
		for i in range(m):
			r = pre[-1][0] - pre[i][0]
			d = 0
			if i:
				d = pre[i - 1][1]
			mnx = min(mnx, max(r, d))
		if mnx == inf:
			mnx = 0
		print(mnx)
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	m = int(stdin.readline())
	a1 = [int(x) for x in stdin.readline().split()]
	a2 = [int(x) for x in stdin.readline().split()]
	top = sum(a1) - a1[0]
	bottom = 0
	answer = top
	for i in range(m - 1):
		top -= a1[i + 1]
		bottom += a2[i]
		answer = min(answer, max(top, bottom))
	stdout.write(str(answer) + '\n')


def solve(upper, lower, n):
	sum_upper = [0] * n
	sum_lower = [0] * n
	upper_row = 0
	lower_row = 0
	for x in range(n):
		upper_row += upper[x]
		lower_row += lower[x]
		sum_upper[x] = upper_row
		sum_lower[x] = lower_row
	alice = [0] * n
	bob = [0] * n
	alice[0] = upper[0] + lower_row
	bob[0] = upper_row - upper[0]
	result = bob[0]
	for x in range(1, n):
		alice[x] = alice[x - 1] + upper[x] - lower[x - 1]
		bob[x] = max(sum_upper[n - 1] - sum_upper[x], sum_lower[x - 1])
		if bob[x] <= result:
			result = bob[x]
	print(result)
for _ in range(int(input())):
	n = int(input())
	solve(list(map(int, input().split())), list(map(int, input().split())), n)


for _ in range(int(input())):
	m = int(input())
	arr = [list(map(int, input().split())), list(map(int, input().split()))]
	prefix1 = [0]
	for num in arr[0]:
		prefix1.append(prefix1[-1] + num)
	prefix2 = [0]
	for num in arr[1]:
		prefix2.append(prefix2[-1] + num)
	ans = float('inf')
	for i in range(1, m + 1):
		ans = min(ans, max(prefix1[m] - prefix1[i], prefix2[i - 1]))
	print(ans)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	m = int(input())
	i1 = list(map(int, input().split()))
	i2 = list(map(int, input().split()))
	su1 = sum(i1)
	su2 = sum(i2)
	res = []
	resd1 = 0
	resd2 = su2
	for i in range(m):
		resd1 += i1[i]
		res.append(max(su1 - resd1, su2 - resd2))
		resd2 -= i2[i]
	print(min(res))


import sys
MOD = 1000000007

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

def ii():
	return int(inp())

def iis():
	return [int(i) for i in inp().split()]

def solve():
	m = ii()
	a1 = iis()
	a2 = iis()
	a1pre = [a1[0]]
	a2pre = [a2[0]]
	for i in range(1, m):
		a1pre.append(a1pre[-1] + a1[i])
		a2pre.append(a2pre[-1] + a2[i])
	ans = MOD
	ans = min(ans, a1pre[-1] - a1pre[0])
	for i in range(1, m):
		ans = min(ans, max(a2pre[i - 1], a1pre[-1] - a1pre[i]))
	return ans
t = ii()
for _ in range(t):
	print(solve())


n = int(input())
for i in range(n):
	l1 = []
	l2 = []
	m = int(input())
	g1 = input()
	g1 = g1.split()
	g2 = input()
	g2 = g2.split()
	for o in g1:
		l1.append(int(o))
	for o in g2:
		l2.append(int(o))
	s = sum(l1)
	z1 = sum(l1) - l1[0]
	z2 = 0
	zaehler = -1
	speicher = 1000000000
	speicher2 = 1000000000
	for x in range(len(l1) - 1):
		z1 -= l1[x + 1]
		z2 += l2[x]
		if max(z1, z2) < speicher:
			speicher = max(z1, z2)
		if max(z1, z2) > speicher2:
			break
		speicher2 = speicher
	if speicher == 1000000000:
		speicher = 0
	elif speicher > sum(l1) - l1[0]:
		speicher = sum(l1) - l1[0]
	print(speicher)


from itertools import accumulate
from sys import stdin, gettrace
if gettrace():

	def inputi():
		return input()
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	m = int(input())
	aa1 = [int(a) for a in input().split()]
	aa2 = [int(a) for a in input().split()]
	acc1 = list(accumulate(aa1))
	acc2 = [0] + list(accumulate(aa2))
	res = min((max(acc2[i], acc1[-1] - acc1[i]) for i in range(m)))
	print(res)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


import os, sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		a = [[0] + list(map(int, input().split())) for _ in range(2)]
		for i in range(2):
			for j in range(1, n + 1):
				a[i][j] += a[i][j - 1]
		print(min((max(a[0][n] - a[0][i], a[1][i - 1]) for i in range(1, n + 1))))
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()


t = int(input())
for i in range(t):
	m = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pr1 = [0] * m
	pr2 = [0] * m
	pr1[0] = a[0]
	pr2[0] = b[0]
	for j in range(1, m):
		pr1[j] = pr1[j - 1] + a[j]
		pr2[j] = pr2[j - 1] + b[j]
	pos = 0
	ans = pr1[-1] - pr1[0]
	for j in range(1, m):
		ans = min(ans, max(pr1[-1] - pr1[j], pr2[j - 1]))
	print(ans)


import sys, math

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

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

def main():
	for _ in range(int(input())):
		n = int(input())
		ls = []
		for i in range(2):
			x = get_ls()
			ls.append(x)
		sum1 = sum(ls[0])
		sum2 = 0
		ans = math.inf
		for i in range(n):
			sum1 -= ls[0][i]
			ans = min(ans, max(sum1, sum2))
			sum2 += ls[1][i]
		print(ans)
main()


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

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

def score(matrix):
	first_row_sum = sum(matrix[0])
	second_row_sum = 0
	max_score = float('inf')
	for i in range(len(matrix[0])):
		sum_one = first_row_sum - matrix[0][i]
		if first_row_sum - matrix[0][i] != 0:
			first_row_sum -= matrix[0][i]
		sum_two = second_row_sum
		second_row_sum += matrix[1][i]
		max_score = min(max_score, max(sum_one, sum_two))
	print(max_score)
n = inp()
matrices = []
for i in range(n):
	m = inp()
	tmp = []
	for _ in range(2):
		line = invr()
		tmp.append(line)
	matrices.append(tmp)
for matrix in matrices:
	score(matrix)


import sys
import math
import random
from queue import PriorityQueue as PQ
from bisect import bisect_left as BSL
from bisect import bisect_right as BSR
from collections import OrderedDict as OD
from collections import Counter
from itertools import permutations
mod = 1000000007
try:
	sys.stdin = open('actext.txt', 'r')
	OPENFILE = 1
except:
	pass

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

def palindrome(s):
	mid = len(s) // 2
	for i in range(mid):
		if s[i] != s[len(s) - i - 1]:
			return False
	return True

def check(i, n):
	if 0 <= i < n:
		return True
	else:
		return False
t = int(input())
for tt in range(t):
	m = int(input())
	arr = []
	for i in range(2):
		arr.append(list(map(int, input().split())))
	if m == 1:
		print(0)
	else:
		sumarr = [[], []]
		sm1 = 0
		sm2 = 0
		for i in range(m - 1, -1, -1):
			sm1 += arr[0][i]
			sumarr[0].insert(0, sm1)
		for i in range(m):
			sm2 += arr[1][i]
			sumarr[1].append(sm2)
		ans = sum(sumarr[0]) + sum(sumarr[1])
		for i in range(0, m - 1):
			temp = max(sumarr[0][i] - arr[0][i], sumarr[1][i] - arr[1][i])
			ans = min(ans, temp)
		ans = min(ans, sumarr[1][m - 2])
		print(ans)


for _ in range(int(input())):
	m = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = sum(b)
	sa = sum(a)
	pref_a = [a[0]]
	pref_b = [b[0]]
	for i in range(1, m):
		pref_a.append(pref_a[i - 1] + a[i])
		pref_b.append(pref_b[i - 1] + b[i])
	el = 0
	while pref_b[el] < sa - pref_a[el]:
		el += 1
		if el >= m - 1:
			el = m - 1
			break
	if el == 0:
		print(sa - a[0])
	else:
		print(max(sa - pref_a[el], pref_b[el - 1]))