Watson gives Sherlock an array of integers.  His challenge is to find an element of the array such that the sum of all elements to the left is equal to the sum of all elements to the right.  

Example  

$arr=[5,6,8,11]$  

$8$ is between two subarrays that sum to $\mbox{11}$.  

$arr=[1]$  

The answer is $[1]$ since left and right sum to $0$.

You will be given arrays of integers and must determine whether there is an element that meets the criterion.  If there is, return YES.  Otherwise, return NO.

Function Description  

Complete the balancedSums function in the editor below.  

balancedSums has the following parameter(s):  

int arr[n]: an array of integers  

Returns  

string:  either YES or NO  

Input Format

The first line contains $T$, the number of test cases.  

The next $T$ pairs of lines each represent a test case. 

- The first line contains $n$, the number of elements in the array $arr$. 

- The second line contains $n$ space-separated integers $arr[i]$ where $0\leq i<n$.  

Constraints

$1\leq T\leq10$ 

$1\leq n\leq10^5$ 

$1\leq\textit{arr}[i]\leq2\times10^4$ 

$0\leq i<n$

Sample Input 0
2
3
1 2 3
4
1 2 3 3

Sample Output 0
NO
YES

Explanation 0

For the first test case, no such index exists. 

For the second test case, $arr[0]+ar r[1]=ar r[3]$, therefore index $2$ satisfies the given conditions.

Sample Input 1
3
5
1 1 4 1 1
4
2 0 0 0
4
0 0 2 0 

Sample Output 1
YES
YES
YES

Explanation 1

In the first test case, $arr[2]=4$ is between two subarrays summing to $2$. 

In the second case, $arr[0]=2$ is between two subarrays summing to $0$. 

In the third case, $arr[2]=2$ is between two subarrays summing to $0$.

Difficulty: EASY
Tags: Complete search
Skill types: Complete search

Starter code:

Solutions:
for t in range(int(input())):
	n = int(input())
	a = [int(b) for b in input().split()]
	s = sum(a)
	count = 0
	for i in range(n):
		if 2 * count == s - a[i]:
			print('YES')
			break
		count += a[i]
	else:
		print('NO')


T = int(input())
for _ in range(T):
	N = int(input())
	xs = [int(x) for x in input().split()]
	s = sum(xs)
	lefts = 0
	for (i, x) in enumerate(xs):
		lefts += xs[i - 1] if i >= 1 else 0
		rights = s - x - lefts
		if rights == lefts:
			print('YES')
			break
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	(sm, left) = (sum(arr), 0)
	for (i, x) in enumerate(arr):
		left += 0 if i == 0 else arr[i - 1]
		if left == sm - x - left:
			print('YES')
			break
	else:
		print('NO')


import sys
T = int(sys.stdin.readline())
for t in range(T):
	N = int(sys.stdin.readline())
	elements = [int(nbr) for nbr in sys.stdin.readline().split()]
	leftarr = []
	ack = 0
	leftarr.append(ack)
	for element in elements:
		ack += element
		leftarr.append(ack)
	rightarr = []
	rightack = 0
	rightarr.append(rightack)
	pos = len(leftarr) - 1
	for elements in reversed(elements):
		rightack += elements
		if leftarr[pos] == rightack:
			print('YES')
			break
		pos -= 1
		if pos == 0:
			print('NO')
			break


for _ in range(int(input())):
	N = int(input())
	a = [int(c) for c in input().split()[:N]]
	all_sum = sum(a)
	left_sum = 0
	ans = 'NO'
	for i in a:
		if left_sum == all_sum - left_sum - i:
			ans = 'YES'
			break
		left_sum += i
	print(ans)


cases = []
T = int(input())
for i in range(T):
	N = int(input())
	cases.append([x for x in map(int, input().strip().split())])
for case in cases:
	found_index = False
	left = 0
	right = sum(case)
	for i in case:
		right -= i
		if right == left:
			found_index = True
		left += i
	if found_index:
		print('YES')
	else:
		print('NO')


def foo(array):
	if not array:
		return False
	if len(array) == 1:
		return True
	array_sum = sum(array)
	prefix_sum = 0
	for e in array:
		if array_sum - prefix_sum - e == prefix_sum:
			return True
		prefix_sum += e
	return False
T = int(input())
for _ in range(T):
	N = int(input())
	array = map(int, input().split())
	if foo(list(array)):
		print('YES')
	else:
		print('NO')


t = int(input())
for caseNr in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	sum = 0
	for x in arr:
		sum += x
	tmp = 0
	res = False
	for x in arr:
		if tmp == sum - x - tmp:
			res = True
		tmp += x
	if res:
		print('YES')
	else:
		print('NO')


T = int(input())
for Ti in range(T):
	N = int(input())
	A = [int(v) for v in input().split()]
	Al = 0
	Ar = sum(A)
	result = False
	for Ai in A:
		Ar -= Ai
		if Al == Ar:
			result = True
			break
		Al += Ai
	print('YES' if result else 'NO')


def check(array):
	right = sum(array)
	left = 0
	for i in range(len(array)):
		right -= array[i]
		if left == right:
			return 'YES'
		left += array[i]
	return 'NO'
cases = int(input())
for i in range(cases):
	length = int(input())
	nums = list(map(int, input().split()))
	ans = check(nums)
	print(ans)


for t in range(int(input())):
	n = int(input())
	ns = list(map(int, input().split()))
	sum_l = 0
	sum_r = 0
	i_l = 0
	i_r = n - 1
	while i_r > i_l:
		if sum_l + ns[i_l] < sum_r + ns[i_r]:
			sum_l += ns[i_l]
			i_l += 1
		else:
			sum_r += ns[i_r]
			i_r -= 1
	print('YES' if sum_l == sum_r else 'NO')


for i in range(int(input())):
	input()
	a = list(map(int, input().split()))
	(lsum, rsum) = (0, sum(a))
	for e in a:
		rsum -= e
		if lsum == rsum:
			print('YES')
			break
		lsum += e
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	rightSum = sum(arr)
	leftSum = 0
	for i in range(n):
		rightSum = rightSum - arr[i]
		if leftSum == rightSum:
			print('YES')
			break
		leftSum += arr[i]
	else:
		print('NO')


def testsum(ar, cut):
	if sum(ar[:cut]) == sum(ar[cut + 1:]):
		return 0
	elif sum(ar[:cut]) < sum(ar[cut + 1:]):
		return 1
	elif sum(ar[:cut]) > sum(ar[cut + 1:]):
		return -1

def rectest(ar, c, u, l):
	test = testsum(ar, c)
	if test == 0:
		return 'YES'
	elif abs(u - l) == 1:
		return 'NO'
	elif test == 1:
		(c, l) = ((c + u) // 2, c)
		return rectest(ar, c, u, l)
	elif test == -1:
		(c, u) = ((c + l) // 2, c)
		return rectest(ar, c, u, l)
t = eval(input())
for _ in range(t):
	n = eval(input())
	a = list(map(int, input().split()))
	res = rectest(a, n // 2, n, 0)
	print(res)


t = int(input())
for _ in range(t):
	n = int(input())
	nbs = [int(i) for i in input().split()]
	u = sum(nbs[1:])
	v = 0
	found = u == v
	for i in range(1, n):
		if u == v:
			found = True
			break
		else:
			u -= nbs[i]
			v += nbs[i - 1]
	if found:
		print('YES')
	else:
		print('NO')


T = int(input())
for line in range(T):
	N = int(input())
	A = [int(x) for x in input().split()]
	total = sum(A)
	left = 0
	right = total
	mid = 0
	found = False
	for i in range(len(A)):
		left += mid
		mid = A[i]
		right -= mid
		if left == right:
			print('YES')
			found = True
			break
	if not found:
		print('NO')


cases = int(input())
for i in range(cases):
	n = int(input())
	a_array = [int(j) for j in str(input()).split()]
	left = 0
	right = sum(a_array)
	for j in a_array:
		right -= j
		if left < right:
			left += j
		elif left == right:
			print('YES')
			break
		else:
			print('NO')
			break


def equalPartsExist(size, arr):
	(l, r) = (0, sum(arr))
	for i in range(size):
		r -= arr[i]
		if l == r:
			return 'YES'
		else:
			l += arr[i]
	return 'NO'
for _ in range(int(input())):
	print(equalPartsExist(int(input()), list(map(int, input().split()))))


import sys

def main():
	cases = int(input())
	for c in range(cases):
		sizeof = int(input())
		left_sum = 0
		right_sum = 0
		arr = []
		for val in input().split():
			right_sum += int(val)
			arr.append(int(val))
		right_sum -= arr[0]
		if right_sum == left_sum:
			print('YES')
		else:
			for i in range(len(arr) - 1):
				right_sum -= arr[i + 1]
				left_sum += arr[i]
				if right_sum == left_sum:
					print('YES')
					break
			else:
				print('NO')
main()


k = int(input())
for i in range(k):
	br = 0
	n = int(input())
	array = []
	array1 = []
	for item in input().split():
		array.append(int(item))
	array1.append(array[0])
	for p in range(1, n):
		array1.append(array1[p - 1] + array[p])
	if array1[n - 1] - array1[0] == 0:
		print('YES')
		continue
	for q in range(1, n):
		if array1[q - 1] == array1[n - 1] - array1[q]:
			print('YES')
			br = 1
			break
	if br == 1:
		continue
	if array1[n - 1] == 0:
		print('YES')
		continue
	print('NO')


def sum_checker(lst):
	(previous_sum, full_sum) = (0, sum(lst))
	for (i, _) in enumerate(lst):
		full_sum -= lst[i]
		if previous_sum == full_sum:
			return True
		previous_sum += lst[i]
	return False
t = int(input())
for i in range(t):
	_ = int(input())
	nums = [int(el) for el in input().strip().split()]
	print('YES' if sum_checker(nums) else 'NO')


from sys import stdin

def main():
	K = int(stdin.readline())
	for i in range(K):
		N = int(stdin.readline())
		A = list(map(int, stdin.readline().strip().split()))
		print(is_sherlock(A, N))

def is_sherlock(A, N):
	sumr = sum(A)
	suml = 0
	for i in range(N):
		sumr -= A[i]
		if suml == sumr:
			return 'YES'
		suml += A[i]
	return 'NO'
main()


t = int(input())
for _ in range(t):
	input()
	a = list(map(int, input().split()))
	tot = sum(a)
	part = 0
	for i in a:
		if part == tot - i - part:
			print('YES')
			break
		part += i
		if part + part > tot:
			print('NO')
			break


for t in range(int(input())):
	input()
	data = map(int, input().split())
	sum = 0
	new_data = []
	for x in data:
		sum += x
		new_data.append(sum)
	for i in range(len(new_data)):
		sum_left = 0 if i == 0 else new_data[i - 1]
		sum_right = 0 if i + 1 == len(new_data) else new_data[-1] - new_data[i]
		if sum_left == sum_right:
			break
	else:
		print('NO')
		continue
	print('YES')


def LeftRight(numbers):
	numbers.insert(0, 0)
	L = 0
	R = sum(numbers)
	for i in range(1, len(numbers)):
		L += numbers[i - 1]
		R -= numbers[i]
		if L == R:
			return 'YES'
	return 'NO'
T = int(input())
for i in range(0, T):
	N = int(input())
	numsArr = [int(i) for i in input().split()]
	print(LeftRight(numsArr))


for T in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	s = 'NO'
	(l, r) = (0, sum(A))
	for i in range(N):
		if i:
			l += A[i - 1]
		r -= A[i]
		if l == r:
			s = 'YES'
			break
	print(s)


import sys
DEV = False

def Inc(Max_, Start_=0, Increment_=1):
	for num in range(Start_, Max_, Increment_):
		yield num
if DEV:
	f = open('test_data.txt', 'r')
	T = int(f.readline().strip())
else:
	T = int(input().strip())
for tests in Inc(T):
	if DEV:
		N = int(f.readline().strip())
		ra = [int(num) for num in f.readline().strip().split()]
	else:
		N = int(input().strip())
		ra = [int(num) for num in input().strip().split()]
	left = 0
	right = sum(ra[1:])
	if not right:
		print('YES')
		continue
	left = ra[0]
	for idx in Inc(N, 1, 1):
		right -= ra[idx]
		if left >= right:
			break
		left += ra[idx]
	if left == right:
		print('YES')
	else:
		print('NO')
if DEV:
	f.close()


test = int(input())
out = []
for j in range(test):
	number = int(input())
	symbol = str(input())
	symbol = symbol.split()
	symbol = list(map(int, symbol))
	summ = 0
	lstsumm = sum(symbol)
	for i in range(len(symbol)):
		summ += symbol[i]
		if summ - symbol[i] >= lstsumm - summ:
			if summ - symbol[i] == lstsumm - summ:
				print('YES')
				break
			else:
				print('NO')
				break


t = int(input())
for i in range(0, t):
	listlength = int(input())
	list = input().split()
	(left, right, answer) = (0, 0, 'NO')
	for k in range(1, listlength):
		right = right + int(list[k])
	if (left == 0) & (right == 0):
		answer = 'YES'
	j = 0
	while (j < listlength) & (answer == 'NO'):
		j = j + 1
		left = left + int(list[j - 1])
		if j < listlength:
			right = right - int(list[j])
		else:
			right = 0
		if left == right:
			answer = 'YES'
	if listlength == 1:
		answer = 'YES'
	print(answer)


def TestArray(ar):
	N = len(ar)
	RightTotal = sum(ar) - ar[0]
	LeftTotal = 0
	i = 0
	while LeftTotal < RightTotal and i < N:
		i = i + 1
		LeftTotal = LeftTotal + ar[i - 1]
		RightTotal = RightTotal - ar[i]
	if LeftTotal == RightTotal and i < N:
		return 'YES'
	else:
		return 'NO'
T = int(input())
while T:
	T = T - 1
	N = int(input())
	ar = [int(i) for i in input().split()]
	print(TestArray(ar))


T = int(input())
for test in range(T):
	size = int(input())
	ar = list(map(int, input().split()))
	total = sum(ar)
	left = 0
	right = total - ar[0]
	i = 0
	while right > left and i < size:
		left += ar[i]
		i += 1
		right -= ar[i]
	if left == right:
		print('YES')
	else:
		print('NO')


def f(A):
	s = sum(A)
	st = 0
	for i in range(len(A)):
		if st == s - st - A[i]:
			return True
		if st > s - st - A[i]:
			break
		st += A[i]
	return False
for _ in range(int(input())):
	input()
	print('YES' if f([int(i) for i in input().split()]) else 'NO')


import sys
cases = int(sys.stdin.readline())
for i in range(cases):
	leng = int(sys.stdin.readline())
	lst = sys.stdin.readline().strip().split()
	lst = list(map(int, lst))
	right = sum(lst) - lst[0]
	left = 0
	success = False
	if right == left:
		success = True
	else:
		for j in range(1, leng):
			right -= lst[j]
			left += lst[j - 1]
			if right == left:
				success = True
				break
	if success == True:
		print('YES')
	else:
		print('NO')


def hasProperty(array):
	sumLeft = 0
	sumRight = 0
	for i in range(1, len(array)):
		sumRight += array[i]
	i = 0
	if sumLeft == sumRight:
		return 'YES'
	while i < len(array) - 1:
		sumLeft += array[i]
		sumRight -= array[i + 1]
		if sumLeft == sumRight:
			return 'YES'
		i += 1
	return 'NO'
numOfInputs = int(input())
for i in range(numOfInputs):
	N = input()
	array = [int(x) for x in input().split()]
	print(hasProperty(array))


for case in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	if N == 1:
		print('YES')
		continue
	result = False
	(left, right) = (0, sum(A[1:]))
	for i in range(len(A) - 1):
		if left == right:
			result = True
			break
		else:
			left += A[i]
			right -= A[i + 1]
	print('YES' if result else 'NO')


output = []
for _ in range(int(input())):
	size_of_array = int(input())
	if size_of_array == 1:
		output.append('YES')
	else:
		output.append('NO')
	array_of_integers = [int(i) for i in input().split()]
	end = len(array_of_integers)
	j = int(end / 2)
	sum_below = sum(array_of_integers[:j])
	sum_above = sum(array_of_integers[j + 1:])
	while sum_below < sum_above and j < end:
		j += 1
		sum_below += array_of_integers[j - 1]
		sum_above -= array_of_integers[j]
	while sum_below > sum_above and j > 0:
		j -= 1
		sum_below -= array_of_integers[j]
		sum_above += array_of_integers[j + 1]
	if sum_below == sum_above:
		output[-1] = 'YES'
for k in output:
	print(k)


for t in [1] * int(input()):
	n = int(input())
	a = list(map(int, input().split()))
	sum1 = 0
	sum2 = sum(a[1:])
	if sum1 == sum2:
		print('YES')
	else:
		for i in range(n - 1):
			sum1 += a[i]
			sum2 -= a[i + 1]
			if sum1 == sum2:
				print('YES')
				break
		else:
			print('NO')


def main():
	for case in range(int(input())):
		n = int(input())
		numbers = [int(x) for x in str(input()).split()]
		print(check(numbers))

def check(numbers):
	if len(numbers) == 1:
		return 'YES'
	min = 0
	max = len(numbers) - 1
	count = 0
	while count < 20:
		mid = int((min + max) / 2)
		(a, b) = (sum(numbers[0:mid], 0), sum(numbers[mid + 1:], 0))
		if a == b:
			return 'YES'
		if a < b:
			min = mid
		if a > b:
			max = mid
		count += 1
	return 'NO'
main()


def isSherlock(arr):
	isExit = 'NO'
	s = sum(arr)
	leftSum = 0
	for i in range(1, len(arr), 1):
		leftSum += arr[i - 1]
		rightSum = s - arr[i] - leftSum
		if leftSum == rightSum:
			isExit = 'YES'
			break
	print(isExit)

def main():
	T = int(input())
	while T != 0:
		n = int(input())
		arr = [0] + [int(x) for x in input().split()]
		isSherlock(arr)
		T -= 1
main()


def calc(n, arr):
	if n == 1:
		return 'YES'
	else:
		sum = 0
		left_sum = 0
		for v in arr:
			sum += v
		for i in range(n):
			if i > 0:
				left_sum += arr[i - 1]
			if left_sum * 2 + arr[i] == sum:
				return 'YES'
	return 'NO'
T = int(input().strip())
for t in range(T):
	n = int(input().strip())
	arr = [int(i) for i in input().strip().split()]
	print(calc(n, arr))


def eqpoint_exists(a):
	if len(a) == 1:
		return 'YES'
	left = 0
	right = sum(a[1:])
	for i in range(1, len(a)):
		if left == right:
			return 'YES'
		left += a[i - 1]
		right -= a[i]
	return 'NO'
t = int(input().strip())
cases = []
for _ in range(t):
	input().strip()
	cases.append(list(map(int, input().strip().split())))
for c in cases:
	print(eqpoint_exists(c))


def run():
	t = int(input())
	while t > 0:
		t -= 1
		n = int(input())
		ar = list(map(int, input().split()))
		total = 0
		for x in ar:
			total += x
		left = 0
		check = False
		for x in ar:
			if x + 2 * left == total:
				check = True
				break
			left += x
		print('YES' if check else 'NO')
run()


def Sherlock_Array(A):
	N = len(A)
	B = [0] * N
	C = [0] * N
	s = 0
	t = 0
	for i in range(N):
		B[i] = s
		s += A[i]
		C[N - 1 - i] = t
		t += A[N - 1 - i]
	for i in range(N):
		if B[i] == C[i]:
			return 'YES'
	return 'NO'
test_cases = int(input())
for t in range(test_cases):
	N = int(input())
	A = list(map(int, input().split()))
	print(Sherlock_Array(A))


def find_answer(ar):
	sum_left = 0
	sum_right = sum(ar[1:])
	if sum_left == sum_right:
		return 'YES'
	for (i, el) in enumerate(ar):
		sum_left += el
		if i + 1 < len(ar):
			sum_right -= ar[i + 1]
		else:
			sum_right = 0
		if sum_left == sum_right:
			return 'YES'
	return 'NO'
for t in range(int(input())):
	input()
	print(find_answer([int(x) for x in input().split()]))


for t in range(int(input())):
	n = int(input())
	a = [int(b) for b in input().split()]
	s = sum(a)
	count = 0
	for i in range(n):
		if 2 * count == s - a[i]:
			print('YES')
			break
		count += a[i]
	else:
		print('NO')


T = int(input())
for i in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	right = sum(A) - A[0]
	left = 0
	for i in range(1, len(A)):
		if left >= right:
			break
		left += A[i - 1]
		right -= A[i]
	if left == right:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	lef = 0
	rig = n
	l = list(map(int, input().split()))
	if n == 1:
		print('YES')
	elif n == 2:
		print('NO')
	else:
		while lef <= rig:
			m = (lef + rig) // 2
			if sum(l[0:m]) == sum(l[m + 1:n]):
				print('YES')
				break
			elif sum(l[0:m]) < sum(l[m + 1:n]):
				lef = m + 1
			else:
				rig = m - 1
		if lef > rig:
			print('NO')


cases = int(input())
for _ in range(cases):
	output = 'NO'
	length = int(input())
	nums = [int(i) for i in input().split()]
	total = sum(nums)
	current_sum = 0
	for i in range(length):
		target = (total - nums[i]) / 2
		if i != 0:
			current_sum += nums[i - 1]
		if current_sum == target:
			output = 'YES'
			break
		if current_sum > target:
			break
	print(output)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(c) for c in input().split()]
	s1 = 0
	s2 = sum(a[1:])
	if s1 == s2:
		print('YES')
	else:
		for j in range(n - 1):
			if s1 == s2:
				print('YES')
				break
			s1 += a[j]
			s2 -= a[j + 1]
		else:
			print('NO')


T = int(input())
for i in range(T):
	N = int(input())
	A = [int(x) for x in input().split()]
	B = [0, A[0]]
	for j in range(1, N):
		B.append(B[j] + A[j])
	B.append(B[-1])
	good = False
	for j in range(1, len(B) - 1):
		if B[len(B) - 1] - B[j] == B[j - 1]:
			good = True
	if good:
		print('YES')
	else:
		print('NO')


t = int(input())
for T in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	right = sum(a) - a[0]
	left = 0
	good = n == 1
	if right == left:
		good = True
	if right == sum(a[0:-1]):
		good = True
	for i in range(1, len(a) - 1):
		left += a[i - 1]
		right -= a[i]
		if left == right:
			good = True
			break
	if good:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	numbers = [int(x) for x in input().strip().split()]
	sums = []
	cur_sum = 0
	for i in range(n):
		sums.append(cur_sum)
		cur_sum += numbers[i]
	for i in range(n):
		if sums[i] == cur_sum - sums[i] - numbers[i]:
			print('YES')
			break
	else:
		print('NO')


n = int(input())
for _ in range(n):
	fl = 0
	m = int(input())
	num = input().split()
	num = [int(i) for i in num]
	s = sum(num)
	ts = 0
	for i in num:
		if ts == s - ts - i:
			fl = 1
			break
		ts = ts + i
	if fl == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	length = input()
	s = [int(i) for i in input().split()]
	left = 0
	right = sum(s[1:])
	if left == right:
		print('YES')
		continue
	rekt = True
	for (i, x) in enumerate(s):
		if i == 0:
			continue
		left += s[i - 1]
		right -= x
		if left == right:
			print('YES')
			rekt = False
			break
	if rekt:
		print('NO')


def solver(array):
	leftside = 0
	rightside = sum(array) - array[0]
	for j in range(len(array) - 1):
		if leftside == rightside:
			return 'YES'
		else:
			leftside += array[j]
			rightside -= array[j + 1]
	return 'NO'
T = int(input())
for i in range(T):
	toss = input()
	array = input().strip().split()
	for j in range(len(array)):
		array[j] = int(array[j])
	array.append(0)
	print(solver(array))


def sherlockAndArray(ar, N):
	if N == 1:
		return 'YES'
	else:
		sum_left = 0
		sum_right = sum(ar)
		for i in range(N):
			sum_right -= ar[i]
			if sum_left == sum_right:
				return 'YES'
			sum_left += ar[i]
	return 'NO'
T = int(input())
for i in range(T):
	N = int(input())
	ar = [int(x) for x in input().split()]
	print(sherlockAndArray(ar, N))


def foo(ar):
	left_sum = 0
	right_sum = sum(ar[1:])
	prev = ar[0]
	if left_sum == right_sum:
		return 'YES'
	for x in ar[1:]:
		left_sum += prev
		right_sum -= x
		prev = x
		if left_sum == right_sum:
			return 'YES'
	return 'NO'
t = int(input())
for _ in range(t):
	n = int(input())
	ar = [int(x) for x in input().split()]
	print(foo(ar))


T = int(input())
for j in range(T):
	answer = 'NO'
	N = int(input())
	if N == 1:
		answer = 'YES'
	A = [int(k) for k in input().split()]
	lsum = 0
	rsum = sum(A[1:])
	for i in range(N - 1):
		if lsum == rsum:
			answer = 'YES'
		lsum += A[i]
		rsum -= A[i + 1]
	print(answer)


T = int(input())
for i in range(T):
	N = int(input())
	array = list(map(int, input().split()))
	lsum = 0
	rsum = 0
	for i in range(N):
		rsum += array[i]
	flag = False
	i = 0
	while i < N and (not flag):
		rsum -= array[i]
		if lsum == rsum:
			flag = True
		else:
			lsum += array[i]
		i += 1
	print('YES' if flag else 'NO')


T = int(input())
for i in range(T):
	n = int(input())
	inputs = [int(j) for j in input().split()]
	flag = 0
	total = sum([inputs[l] for l in range(n)])
	total1 = 0
	for k in range(n):
		if total1 == total - total1 - inputs[k]:
			print('YES')
			flag = 1
			break
		total1 += inputs[k]
	if flag == 0:
		print('NO')


def condition_satisfies(a, start, end, it):
	m = start + (end - start) // 2
	l = sum(a[:m])
	r = sum(a[m + 1:])
	if start < end and m != start and (m != end):
		if l < r:
			return condition_satisfies(a, m, end, it + 1)
		elif l > r:
			return condition_satisfies(a, 0, m, it + 1)
		return True
	else:
		return l == r
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print('YES' if condition_satisfies(a, 0, n, 0) else 'NO')


def read_input():
	N = int(input())
	A = input().split()
	A = [int(x) for x in A]
	return (N, A)

def equal_sum_index(N, A):
	left_sum = 0
	right_sum = sum(A[1:N])
	if left_sum == right_sum:
		print('YES')
		return
	iA = 0
	while iA < N - 1:
		left_sum += A[iA]
		iA += 1
		right_sum -= A[iA]
		if left_sum == right_sum:
			print('YES')
			return
	print('NO')
	return
T = int(input())
for _ in range(T):
	(N, A) = read_input()
	equal_sum_index(N, A)


T = int(input())
for i in range(T):
	N = int(input())
	watson_list = input().split()
	watson_list = [int(x) for x in watson_list]
	left_sum = 0
	right_sum = sum(watson_list)
	contains_valid_value = False
	for x in range(N):
		right_sum -= watson_list[x]
		if right_sum == left_sum:
			print('YES')
			contains_valid_value = True
			break
		left_sum += watson_list[x]
	if not contains_valid_value:
		print('NO')