Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to the sum of elements in the second part. It is not always possible, so Vasya will move some element before dividing the array (Vasya will erase some element and insert it into an arbitrary position).

Inserting an element in the same position he was erased from is also considered moving.

Can Vasya divide the array after choosing the right element to move and its new position?


-----Input-----

The first line contains single integer n (1 ≤ n ≤ 100000) — the size of the array.

The second line contains n integers a_1, a_2... a_{n} (1 ≤ a_{i} ≤ 10^9) — the elements of the array.


-----Output-----

Print YES if Vasya can divide the array after moving one element. Otherwise print NO.


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

Output
YES

Input
5
1 2 3 4 5

Output
NO

Input
5
2 2 3 4 5

Output
YES



-----Note-----

In the first example Vasya can move the second element to the end of the array.

In the second example no move can make the division possible.

In the third example Vasya can move the fourth element by one position to the left.

Difficulty: HARD
Tags: Sorting

Data structures

Implementation
Skill types: Sorting

Data structures

Starter code:

Solutions:
import sys
from collections import Counter
n = int(input())
a = [int(x) for x in input().split()]
s = sum(a)
c1 = Counter(a)
c2 = Counter()
cur = 0
for x in a:
	c1[x] -= 1
	c2[x] += 1
	cur += x
	s1 = cur
	s2 = s - s1
	if s1 == s2:
		print('YES')
		sys.exit()
	if (s2 - s1) % 2 == 1:
		continue
	if s2 > s1:
		if c1[(s2 - s1) // 2] > 0:
			print('YES')
			sys.exit()
	elif c2[(s1 - s2) // 2] > 0:
		print('YES')
		sys.exit()
print('NO')


n = int(input())
arr = [int(x) for x in input().split()]
if n == 1:
	print('NO')
	exit(0)
s = sum(arr)
sp = 0
ss = s
setq = {}
setp = {}
for i in arr:
	setq[i] = setq.get(i, 0) + 1
	setp[i] = 0
for i in range(n):
	sp += arr[i]
	ss -= arr[i]
	setp[arr[i]] += 1
	setq[arr[i]] -= 1
	val = ss - sp
	if val > 0 and (not val & 1):
		val //= 2
		ans = setq.get(val, 0)
		if ans > 0:
			print('YES')
			exit(0)
	elif val < 0 and (not -val & 1):
		val = -val
		val //= 2
		ans = setp.get(val, 0)
		if ans > 0:
			print('YES')
			exit(0)
	elif val == 0:
		print('YES')
		exit(0)
print('NO')


a = int(input())
nums = [int(i) for i in input().split()]
tot = sum(nums)

def runner(lpr):
	total = 0
	used = {}
	for i in range(*lpr):
		used[nums[i]] = 1
		total += nums[i]
		distance = 2 * total - tot
		if distance % 2 == 0 and used.get(distance // 2, -1) != -1:
			print('YES')
			exit(0)
runner((0, a))
runner((a - 1, -1, -1))
print('NO')


def divider(a):
	t = sum(a)
	d = []
	d.append(-t)
	for i in range(len(a)):
		t -= 2 * a[i]
		d.append(-t)
		if t == 0:
			return 'YES'
	for i in range(len(a)):
		s = 2 * a[i]
		j = binary(d, s)
		if j > i and j != -1:
			return 'YES'
		j = binary(d, -s)
		if i >= j and j != -1:
			return 'YES'
	return 'NO'

def binary(a, value):
	hi = len(a)
	lo = -1
	while lo + 1 < hi:
		mi = (lo + hi) // 2
		if a[mi] == value:
			return mi
		if a[mi] < value:
			lo = mi
		else:
			hi = mi
	return -1
n = input()
a = [int(i) for i in input().split()]
print(divider(a))


n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(n):
	if a[i] in d:
		d[a[i]] += 1
	else:
		d[a[i]] = 1
if sum(a) % 2 == 1:
	print('NO')
else:
	i = 0
	lim = sum(a) // 2
	tot = 0
	ans = 'NO'
	d2 = {}
	while i < n:
		tot += a[i]
		d[a[i]] -= 1
		if a[i] in d2:
			d2[a[i]] += 1
		else:
			d2[a[i]] = 1
		if tot < lim:
			x = lim - tot
			if x in d:
				if d[x] > 0:
					ans = 'YES'
					break
		elif tot == lim:
			ans = 'YES'
			break
		else:
			x = tot - lim
			if x in d2:
				if d2[x] > 0:
					ans = 'YES'
					break
		i += 1
	print(ans)


n = int(input())
b = list(map(int, input().split()))
d = dict()
e = dict()
for j in range(n):
	if b[j] in d.keys():
		d[b[j]] += 1
		e[b[j]] += 1
	else:
		d[b[j]] = 1
		e[b[j]] = 1
if sum(b) % 2 != 0:
	print('NO')
else:
	p = sum(b) // 2
	j = 0
	s = 0
	f = 0
	while j < n:
		if s == p:
			f = 1
			break
		if p - s in d.keys() and d[p - s] > 0:
			f = 1
			break
		s += b[j]
		d[b[j]] += -1
		j += 1
	j = 0
	s = 0
	b.reverse()
	while j < n:
		if s == p:
			f = 1
			break
		if p - s in e.keys() and e[p - s] > 0:
			f = 1
			break
		s += b[j]
		e[b[j]] += -1
		j += 1
	if f == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
A = list(map(int, input().split()))
d = dict()
acc = 0
for (i, j) in enumerate(A):
	acc += j
	d[acc] = i
if acc % 2 == 1:
	print('NO')
	exit()
for (i, j) in enumerate(A):
	v = acc // 2 - j
	if v in d and d[v] < i:
		print('YES')
		exit()
	v = acc / 2 + j
	if v in d and d[v] >= i:
		print('YES')
		exit()
print('NO')


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
prefix_sum = [a[0]]
postfix_sum = [a[-1]]
for i in range(1, n):
	prefix_sum.append(prefix_sum[-1] + a[i])
	postfix_sum.append(postfix_sum[-1] + a[-(i + 1)])
if prefix_sum[-1] & 1 or n == 1:
	print('NO')
	sys.exit()
target = prefix_sum[-1] // 2
if target in prefix_sum:
	print('YES')
	sys.exit()
seen_pre = {a[0]}
seen_post = {a[-1]}
for i in range(1, n):
	post_i = -(i + 1)
	seen_pre.add(a[i])
	seen_post.add(a[post_i])
	if prefix_sum[i] > target and prefix_sum[i] - target in seen_pre:
		print('YES')
		sys.exit()
	if postfix_sum[i] > target and postfix_sum[i] - target in seen_post:
		print('YES')
		sys.exit()
print('NO')


from bisect import bisect
from sys import stdin, stdout
input = stdin.readline
print = stdout.write
n = int(input())
a = list(map(int, input().split()))
su = sum(a)
if su % 2 == 0:
	su //= 2
	ch = False
	for _ in range(2):
		if ch:
			break
		find = set()
		t = 0
		for i in a:
			t += i
			find.add(i)
			if t - su in find:
				ch = True
				print('YES')
				break
		a.reverse()
	if not ch:
		print('NO')
else:
	print('NO')


from collections import defaultdict

class Solution:

	def division(n, a):
		(prefix_sum, suffix_sum) = ([0] * n, [0] * n)
		(prefix_sum[0], suffix_sum[n - 1]) = (a[0], a[n - 1])
		for i in range(1, n):
			prefix_sum[i] = prefix_sum[i - 1] + a[i]
			suffix_sum[n - 1 - i] = suffix_sum[n - i] + a[n - 1 - i]
		(prefix_check, suffix_check) = (defaultdict(bool), defaultdict(bool))
		for i in range(n):
			prefix_check[a[i]] = True
			diff = prefix_sum[i] - (0 if i == n - 1 else suffix_sum[i + 1])
			diff = int(diff / 2) if diff % 2 == 0 else -1 * abs(diff)
			if diff in prefix_check:
				return True
			suffix_check[a[n - 1 - i]] = True
			diff = suffix_sum[n - 1 - i] - (0 if i == n - 1 else prefix_sum[n - 2 - i])
			diff = int(diff / 2) if diff % 2 == 0 else -1 * abs(diff)
			if diff in suffix_check:
				return True
		return False
n = int(input())
a = list(map(int, input().strip(' ').split(' ')))
print('YES' if Solution.division(n, a) else 'NO')


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
d = defaultdict(int)
f = defaultdict(int)

def check(n):
	n = list(set(list(str(n))))
	if len(n) == 1:
		return True
	n.sort()
	if n[0] == '0':
		if len(n) <= 2:
			return True
		else:
			return False
	else:
		return False
n = I()
l = L()
if n == 1:
	print('NO')
elif sum(l) % 2 == 1:
	print('NO')
else:
	for i in l:
		d[i] += 1
	s = sum(l) // 2
	p = 0
	for i in range(n):
		if s > p:
			if d[s - p] > 0:
				print('YES')
				exit()
			else:
				p += l[i]
				f[l[i]] += 1
				d[l[i]] -= 1
		elif s == p:
			print('YES')
			exit()
		elif f[p - s] > 0:
			print('YES')
			exit()
		else:
			p += l[i]
			f[l[i]] -= 1
	print('NO')


import sys

def read_line():
	return sys.stdin.readline()[:-1]

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

def read_int_line():
	return [int(v) for v in sys.stdin.readline().split()]
n = read_int()
a = read_int_line()
d = {}
d[0] = -1
pref = [0] * (n + 1)
for i in range(1, n + 1):
	pref[i] = pref[i - 1] + a[i - 1]
	if a[i - 1] not in d:
		d[a[i - 1]] = i - 1
tot = pref[n]
req = tot // 2
f = False
for i in range(1, n + 1):
	if pref[i] >= req:
		if pref[i] - req in d:
			if d[pref[i] - req] < i:
				f = True
				break
a = a[::-1]
d = {}
d[0] = -1
pref = [0] * (n + 1)
for i in range(1, n + 1):
	pref[i] = pref[i - 1] + a[i - 1]
	if a[i - 1] not in d:
		d[a[i - 1]] = i - 1
tot = pref[n]
req = tot // 2
f1 = False
for i in range(1, n + 1):
	if pref[i] >= req:
		if pref[i] - req in d:
			if d[pref[i] - req] < i:
				f1 = True
				break
if (f or f1) and tot % 2 == 0:
	print('YES')
else:
	print('NO')


n = int(input())
a = list(map(int, input().split()))
s1 = [0] * n
s1[0] = a[0]
for i in range(1, n):
	s1[i] = s1[i - 1] + a[i]
s2 = [0] * n
s2[n - 1] = a[n - 1]
for i in range(n - 2, -1, -1):
	s2[i] = s2[i + 1] + a[i]
s1 = [0] + s1
s2 = s2 + [0]
d = {}
for i in range(n):
	if a[i] not in d:
		d[a[i]] = 1
	else:
		d[a[i]] += 1
t = {}
for i in range(n + 1):
	diff = s1[i] - s2[i]
	if diff == 0:
		print('YES')
		exit()
	elif diff < 0 and diff % 2 == 0:
		if abs(diff) // 2 in d:
			print('YES')
			exit()
	elif diff > 0 and diff % 2 == 0:
		if abs(diff) // 2 in t:
			print('YES')
			exit()
	if i < n:
		d[a[i]] -= 1
		if d[a[i]] == 0:
			del d[a[i]]
		if a[i] not in t:
			t[a[i]] = 1
		else:
			t[a[i]] += 1
print('NO')


def solve(a):
	s = sum(a)
	if s % 2 == 1:
		return False
	s //= 2
	elements = set()
	cs = 0
	n = len(a)
	for i in range(n):
		cs += a[i]
		if cs == s:
			return True
		elements.add(a[i])
		if i > 0 and cs > s and (cs - s in elements):
			return True
	return False

def main():
	n = int(input())
	a = list(map(int, input().split()))
	if solve(a):
		print('YES')
	elif solve(a[::-1]):
		print('YES')
	else:
		print('NO')
main()


def isPossible(v):
	if sum(v) % 2 == 1:
		return False
	ls = 0
	ts = sum(v) // 2
	mp = {}
	for x in v:
		if not x in mp:
			mp[x] = 0
		mp[x] += 1
	for x in v:
		if ts - ls in mp and mp[ts - ls] > 0:
			return True
		ls += x
		mp[x] -= 1
	return False
n = int(input())
v = [int(x) for x in input().split()]
p = isPossible(v)
v.reverse()
p2 = isPossible(v)
if p or p2:
	print('YES')
else:
	print('NO')


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	ok = 0
	Su = sum(a)
	di = dict()
	di[0] = 1
	su = 0
	for i in range(n):
		su += a[i]
		if di.get(a[i] * 2, 0) == 0:
			di[a[i] * 2] = 1
		if di.get(su - Su + su, 0) == 0:
			pass
		else:
			ok = 1
	di.clear()
	di[0] = 1
	su = 0
	for i in range(-1, -n - 1, -1):
		su += a[i]
		if di.get(a[i] * 2, 0) == 0:
			di[a[i] * 2] = 1
		if di.get(su - Su + su, 0) == 0:
			pass
		else:
			ok = 1
	if ok:
		print('YES')
	else:
		print('NO')
solve()


import math

def f():
	n = int(input())
	s1 = 0
	s2 = 0
	m1 = {}
	m2 = {}
	A = list(map(int, input().split()))
	if n == 1:
		print('NO')
		return
	for i in A:
		s2 += i
		if i in m2:
			m2[i] += 1
		else:
			m2[i] = 1
	for i in A:
		if (s1 - s2) % 2 == 0:
			d = (s1 - s2) // 2
			if d < 0 and -d in m2 and (m2[-d] > 0):
				print('YES')
				return
			elif d in m1 and m1[d] > 0:
				print('YES')
				return
		s1 += i
		s2 -= i
		if i in m1:
			m1[i] += 1
		else:
			m1[i] = 1
		m2[i] -= 1
	print('NO')
	return
f()


n = int(input())
a = [int(x) for x in input().split()]
l = [0]
for x in a:
	l.append(l[-1] + x)
r = [0]
for x in reversed(a):
	r.append(r[-1] + x)
r = r[::-1]
(ls, rs) = ({}, {})
for x in a:
	rs.setdefault(x, 0)
	rs[x] += 1
for i in range(n):
	if i > 0:
		x = a[i - 1]
		ls.setdefault(x, 0)
		ls[x] += 1
		rs[x] -= 1
	d = l[i] - r[i]
	if d == 0:
		print('YES')
		break
	if d % 2 == 1:
		continue
	if d > 0 and ls.get(d // 2, 0) > 0:
		print('YES')
		break
	if d < 0 and rs.get(-d // 2, 0) > 0:
		print('YES')
		break
else:
	print('NO')


import sys
from itertools import accumulate

def solve():
	n = int(input())
	a = [int(i) for i in input().split()]
	S = sum(a)
	if S & 1:
		print('NO')
		return
	S //= 2
	ap = set()
	ps = [0] + list(accumulate(a))
	for i in range(1, n + 1):
		x = ps[i] - S
		ap.add(a[i - 1])
		if x == 0 or x in ap:
			print('YES')
			return
	ap = set()
	a = a[::-1]
	ps = [0] + list(accumulate(a))
	for i in range(1, n + 1):
		x = ps[i] - S
		ap.add(a[i - 1])
		if x == 0 or x in ap:
			print('YES')
			return
	print('NO')
solve()


import collections as cc
n = int(input())
l = list(map(int, input().split()))

def ss(l, d):
	f = cc.defaultdict(int)
	d = sum(l) // 2
	t = 0
	for i in range(n):
		t += l[i]
		f[l[i]] += 1
		if t == d:
			return 1
		elif t > d and t - d in f:
			return 1
	return 0
if sum(l) % 2 or n == 1:
	print('NO')
elif ss(l, sum(l) // 2) or ss(l[::-1], sum(l) // 2):
	print('YES')
else:
	print('NO')


import sys, math
Tests = 1
for _ in range(Tests):
	n = int(input())
	a = list(map(int, sys.stdin.readline().split()))
	if sum(a) % 2 == 0:
		req = sum(a) // 2
		half1 = set()
		flag = True
		sum1 = 0
		for i in range(n):
			sum1 += a[i]
			half1.add(a[i])
			if sum1 == req or sum1 - req in half1:
				print('YES')
				flag = False
				break
		if flag:
			a = a[::-1]
			req = sum(a) // 2
			half1 = set()
			flag = True
			sum1 = 0
			for i in range(n):
				sum1 += a[i]
				half1.add(a[i])
				if sum1 == req or sum1 - req in half1:
					print('YES')
					flag = False
					break
		if flag:
			print('NO')
	else:
		print('NO')


n = int(input())
a = [int(x) for x in input().split()]

def helper(b):
	total = sum(b)
	target = total / 2
	s = set()
	if total % 2 != 0:
		return False
	else:
		ans = 0
		for i in b:
			ans += i
			s.add(i)
			if ans == target or (ans - target > 0 and ans - target in s):
				return True
		return False
if helper(a) or helper(a[::-1]):
	print('YES')
else:
	print('NO')


from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
s = sum(arr)
for i in range(5):
	arr.append(0)
if s & 1:
	print('No')
	exit()
front = defaultdict()
back = defaultdict()
front[arr[0]] = 1
for i in range(1, len(arr)):
	back[arr[i]] = back.get(arr[i], 0) + 1
curr = 0
for i in range(n):
	curr = curr + arr[i]
	if curr == s // 2:
		print('Yes')
		exit()
	elif curr < s // 2:
		x = s // 2 - curr
		if x in back and back[x]:
			print('Yes')
			exit()
	elif curr > s // 2:
		y = curr - s // 2
		if y in front and front[y]:
			print('Yes')
			exit()
	front[arr[i + 1]] = front.get(arr[i + 1], 0) + 1
	back[arr[i + 1]] = back.get(arr[i + 1], 0) - 1
print('No')


def find(A):
	total = sum(A)
	if total % 2 == 1:
		return 'NO'
	need = total // 2
	dic = {}
	temp = 0
	for i in range(len(A)):
		temp += A[i]
		if temp == need:
			return 'YES'
		if temp > need:
			if temp - need in dic:
				return 'YES'
		dic[A[i]] = 1
	A = A[::-1]
	dic = {}
	temp = 0
	for i in range(len(A)):
		temp += A[i]
		if temp == need:
			return 'YES'
		if temp > need:
			if temp - need in dic:
				return 'YES'
		dic[A[i]] = 1
	return 'NO'
input()
print(find(list(map(int, input().strip().split(' ')))))


import math
import re

def f(arr, n):
	a = set()
	x = 0
	y = sum(arr)
	res = 'NO'
	for i in range(n):
		x += arr[i]
		y -= arr[i]
		a.add(arr[i])
		q = x - y
		if q % 2 != 0:
			continue
		elif q == 0 or (q > 0 and q / 2 in a):
			res = 'YES'
			break
	return res
n = int(input())
arr = list(map(int, input().split()))
res = f(arr, n)
if res == 'NO':
	arr = arr[::-1]
	res = f(arr, n)
print(res)


from itertools import *
n = int(input())
l = list(map(int, input().split()))
for j in range(0, 2):
	m = {}
	l = [0] + list(reversed(l))
	for i in range(len(l)):
		m[l[i]] = i
	ac = list(accumulate(l))
	s = ac[-1]
	for i in range(0, len(ac) - 1):
		if ac[i] == s / 2 or (s / 2 - ac[i] in m.keys() and m[s / 2 - ac[i]] > i):
			print('YES')
			quit()
print('NO')


def divPos(arr):
	sumArr = sum(arr)
	targetSum = sumArr / 2
	if sumArr % 2 != 0:
		return False
	lArr = set()
	sumlArr = 0
	for i in range(len(arr)):
		lArr.add(arr[i])
		sumlArr += arr[i]
		if sumlArr == targetSum or (sumlArr > targetSum and sumlArr - targetSum in lArr):
			return True
	return False

def __starting_point():
	n = input()
	arr = [int(x) for x in input().split()]
	if divPos(arr) or divPos(arr[::-1]):
		print('YES')
	else:
		print('NO')
__starting_point()


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
if s % 2:
	print('NO')
	exit()
pre = 0
used = set()
flag = False
for rep in range(2):
	for i in range(n):
		pre += a[i]
		used.add(a[i])
		if pre - s // 2 in used:
			flag = True
	a.reverse()
	used = set()
	pre = 0
if flag:
	print('YES')
else:
	print('NO')


from collections import Counter

def good(a):
	total = sum(a)
	if total % 2 == 1:
		return False
	pref = Counter()
	suff = Counter(a)
	s = 0
	for e in a:
		s += e
		pref[e] += 1
		suff[e] -= 1
		if 2 * s == total:
			return True
		elif 2 * s > total:
			if pref[(2 * s - total) // 2] > 0:
				return True
		elif suff[(total - 2 * s) // 2] > 0:
			return True
	return False
n = int(input())
a = list(map(int, input().split()))
print('YES' if good(a) else 'NO')


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
acc = 0
total = sum(a)
if total % 2 == 1:
	print('NO')
	exit()
half = total // 2
cnt_left = Counter({0: 1})
cnt_right = Counter({0: 1})
acc_r = 0
for i in range(n - 1, -1, -1):
	acc_r += a[i]
	cnt_right[acc_r] += 1
acc_l = 0
for i in range(n):
	cnt_right[acc_r] -= 1
	acc_r -= a[i]
	if cnt_right[half - a[i]] or cnt_left[half - a[i]]:
		print('YES')
		exit()
	acc_l += a[i]
	cnt_left[acc_l] += 1
print('NO')


import sys
import bisect
from bisect import bisect_left as lb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0
b = []

def hnbhai(tc):
	n = sb()
	a = sd()
	s = sum(a)
	if s % 2 != 0 or n == 1:
		print('NO')
		return
	s //= 2
	for t in range(2):
		d = {}
		tot = 0
		for i in a:
			d[i] = True
			tot += i
			if d.get(tot - s):
				print('YES')
				return
		a.reverse()
	print('NO')
for _ in range(1):
	hnbhai(_ + 1)


n = int(input())
a = list(map(int, input().strip().split()))
if sum(a) % 2 != 0:
	print('NO')
else:
	b = set([])
	f = sum(a) // 2
	s = 0
	c = 1
	for i in range(n):
		b.add(a[i])
		s = s + a[i]
		if s == f:
			print('YES')
			c = 0
			break
		elif s - f in b:
			print('YES')
			c = 0
			break
	if c == 1:
		a = a[::-1]
		b = set([])
		f = sum(a) // 2
		s = 0
		c = 1
		for i in range(n):
			b.add(a[i])
			s = s + a[i]
			if s == f:
				print('YES')
				c = 0
				break
			elif s - f in b:
				print('YES')
				c = 0
				break
	if c == 1:
		print('NO')


from sys import exit
n = int(input().strip())
ais = list(map(int, input().strip().split()))
iais = [0 for _ in range(n + 1)]
for i in range(n):
	iais[i + 1] = iais[i] + ais[i]
s = iais[-1]
if s % 2 == 1:
	print('NO')
	exit()
s2 = s // 2
if s2 in iais:
	print('YES')
	exit()
ia = list(range(n))
ia.sort(key=lambda i: ais[i], reverse=True)
j = 0
for i in ia:
	while j < n and s2 - iais[j] > ais[i]:
		j += 1
	if s2 - iais[j] == ais[i] and i >= j:
		print('YES')
		exit()
	if s2 - iais[j] < 0:
		break
for i in reversed(ia):
	while j < n and s2 - iais[j] > -ais[i]:
		j += 1
	if s2 - iais[j] == -ais[i] and i < j:
		print('YES')
		exit()
print('NO')


class Dick:

	def __init__(self):
		self.s = 0
		self.m = dict()

	def add(self, x):
		self.s += x
		if x in self.m:
			self.m[x] += 1
		else:
			self.m[x] = 1

	def rm(self, x):
		self.s -= x
		if self.m[x] > 1:
			self.m[x] -= 1
		else:
			self.m.pop(x)

	def shasei(self):
		return self.s

	def ininder(self, x):
		return x in self.m

def ok(a, n):
	w = sum(a)
	if w & 1:
		return 0
	f = Dick()
	s = Dick()
	for x in a:
		s.add(x)
	w //= 2
	for i in range(n):
		if s.ininder(w - f.shasei()) or f.ininder(w - s.shasei()):
			return 1
		f.add(a[i])
		s.rm(a[i])
	return 0
n = int(input())
a = list(map(int, input().split()))
print('YES' if ok(a, n) else 'NO')


def read_ints():
	return list(map(int, input().split()))
n = int(input())
a = [0] + read_ints()
s = a.copy()
for i in range(1, n + 1):
	s[i] += s[i - 1]
total = s[n]
found = False
for x in s:
	if x << 1 == total:
		found = True
		break
else:
	for (i, x) in enumerate(s[1:], 1):

		def search(lo, hi, target):
			while lo <= hi:
				m = lo + hi >> 1
				cur = s[m] << 1
				if cur == target:
					return True
				elif cur < target:
					lo = m + 1
				else:
					hi = m - 1
			return False
		if search(i, n, total + 2 * a[i]) or search(1, i - 1, total - 2 * a[i]):
			found = True
print('YES' if found else 'NO')


n = int(input())
a = list(map(int, input().split()))
sum = [0] * n
sum[0] = a[0]
for i in range(1, n):
	sum[i] = sum[i - 1] + a[i]
s = sum[n - 1]
found = 0
if s % 2 == 0:
	half = s // 2
	u = 0
	l = n - 1
	while u <= l:
		mid = (u + l) // 2
		if sum[mid] == half:
			print('YES')
			exit()
		elif sum[mid] > half:
			l = mid - 1
		else:
			u = mid + 1
for i in range(0, n):
	u = i
	l = n - 1
	if (2 * a[i] + s) % 2 == 0:
		check = (s + 2 * a[i]) // 2
		while u <= l:
			mid = (u + l) // 2
			if sum[mid] == check:
				found = 1
				break
			elif sum[mid] > check:
				l = mid - 1
			else:
				u = mid + 1
		if found == 1:
			break
if found == 0 and n < 10000:
	for i in range(n - 1, -1, -1):
		u = 0
		l = i - 1
		if (s - 2 * a[i]) % 2 == 0 and s - 2 * a[i] > 0:
			check = (s - 2 * a[i]) // 2
			while u <= l:
				mid = (u + l) // 2
				if sum[mid] == check:
					found = 1
					break
				elif sum[mid] > check:
					l = mid - 1
				else:
					u = mid + 1
			if found == 1:
				break
if found == 1:
	print('YES')
else:
	print('NO')


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left, bisect
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import PriorityQueue as pq
n = int(input())
l = list(map(int, input().split()))
x = dc(list)
y = dc(int)
p = [0] * n
p[0] = l[0]
x[l[0]].append(0)
y[l[0]] += 1
for i in range(1, n):
	p[i] = p[i - 1] + l[i]
	x[l[i]].append(i)
	y[l[i]] += 1
if p[-1] % 2:
	print('NO')
elif y[p[-1] // 2] > 0:
	print('YES')
else:
	f = 0
	for i in range(n - 1):
		if p[i] == p[-1] - p[i]:
			f = 1
			break
		if i != 0:
			if p[i] > p[-1] // 2:
				t = p[i] - p[-1] // 2
				if y[t] > 0:
					if x[t][0] <= i:
						f = 1
						break
	if f:
		print('YES')
	else:
		l = l[::-1]
		p = [0] * n
		f = 0
		x = dc(list)
		p[0] = l[0]
		x[l[0]].append(0)
		for i in range(1, n):
			p[i] = p[i - 1] + l[i]
			x[l[i]].append(i)
		for i in range(n - 1):
			if p[i] == p[-1] - p[i]:
				f = 1
				break
			if i != 0:
				if p[i] > p[-1] // 2:
					t = p[i] - p[-1] // 2
					if y[t] > 0:
						if x[t][0] <= i:
							f = 1
							break
		if f:
			print('YES')
		else:
			print('NO')


n = int(input())
z = list(map(int, input().split()))
s = sum(z)
c = s
if c % 2 != 0:
	f = 1
elif z[0] == s / 2 or z[-1] == s / 2:
	f = 0
else:
	f = 1
	for k in range(2):
		d = set()
		c = 0
		for i in range(n):
			d.add(z[i])
			c += z[i]
			if c - s / 2 in d:
				f = 0
				break
		if f == 0:
			break
		z.reverse()
print(['YES', 'NO'][f])


n = int(input())
a = list(map(int, input().split()))
e = set([0])
p = 0
s = sum(a)
if s % 2:
	st = False
else:
	st = True
if st:
	st = False
	for j in range(2):
		for i in a:
			p += i
			e.add(i)
			if p - s // 2 in e:
				st = True
				break
		e = set([0])
		p = 0
		a.reverse()
print('YES' if st else 'NO')


def find(ar: list) -> bool:
	p = [0]
	s = sum(ar)
	if s % 2 != 0:
		return False
	for elm in ar:
		p.append(p[-1] + elm)
		if p[-1] == s >> 1:
			return True
	lk = set()
	n = len(ar)
	for i in range(1, n):
		lk.add(ar[i - 1])
		elm = -(s >> 1) + (p[i] + ar[i])
		if elm in lk:
			return True
	return False
n = int(input())
ar = list(map(int, input().split()))
rar = ar[::-1]
if find(ar) or find(rar):
	print('YES')
else:
	print('NO')


n = int(input())
l = input()
a = []
ma = -1
b = []
im = {}
out = {}
x = 0
yes = False
for i in l.split():
	aux = int(i)
	a.append(aux)
	x += aux
	b.append(x)
	if not aux in out:
		out[aux] = 1
	else:
		out[aux] += 1
	if ma == -1:
		ma = a[0]
	elif ma < a[-1]:
		ma = a[-1]
half = x / 2
if x % 2 == 0 and ma < half:
	for i in range(n):
		num = b[i]
		out[a[i]] -= 1
		if out[a[i]] == 0:
			del out[a[i]]
		if not a[i] in im:
			im[a[i]] = 1
		else:
			im[a[i]] += 1
		if num == half:
			yes = True
			break
		elif num < half and num + ma >= half:
			if half - num in out:
				yes = True
				break
		elif num > half and num - ma <= half:
			if num - half in im:
				yes = True
				break
else:
	yes = ma == half
if yes:
	print('YES')
else:
	print('NO')


import os, io
from sys import stdout
import collections
import random
import math
from operator import itemgetter
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from collections import Counter

def binomial_coefficient(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def powerOfK(k, max):
	if k == 1:
		return [1]
	if k == -1:
		return [-1, 1]
	result = []
	n = 1
	while n <= max:
		result.append(n)
		n *= k
	return result

def prefixSum(arr):
	for i in range(1, len(arr)):
		arr[i] = arr[i] + arr[i - 1]
	return arr

def divisors(n):
	i = 1
	result = []
	while i * i <= n:
		if n % i == 0:
			if n / i == i:
				result.append(i)
			else:
				result.append(i)
				result.append(n / i)
		i += 1
	return result
n = int(input())
l = list(map(int, input().split()))
rs = Counter(l)
ls = collections.defaultdict(int)
left = prefixSum(l[:])
right = prefixSum(l[::-1])[::-1]
found = False
for i in range(0, n):
	rs[l[i]] -= 1
	ls[l[i]] += 1
	if left[i] == right[i] - l[i]:
		found = True
		print('YES')
		break
	if left[i] > right[i] - l[i]:
		diff = left[i] - (right[i] - l[i])
		if diff % 2 != 0:
			continue
		if diff // 2 in ls and ls[diff // 2] > 0:
			found = True
			print('YES')
			break
	else:
		diff = right[i] - l[i] - left[i]
		if diff % 2 != 0:
			continue
		if diff // 2 in rs and rs[diff // 2] > 0:
			found = True
			print('YES')
			break
if not found:
	print('NO')


def solve(n, a):
	tot = 0
	for i in range(n):
		tot += a[i]
	diffs = []
	diffs.append(-tot)
	for i in range(n):
		tot -= 2 * a[i]
		diffs.append(-tot)
		if tot == 0:
			return 'YES'
	for i in range(n):
		diffmake = 2 * a[i]
		j = binary(diffs, diffmake)
		if j > i and j != -1:
			return 'YES'
		j = binary(diffs, -diffmake)
		if i >= j and j != -1:
			return 'YES'
	return 'NO'

def binary(a, value):
	hi = len(a)
	lo = -1
	while lo + 1 < hi:
		mi = (lo + hi) // 2
		if a[mi] == value:
			return mi
		if a[mi] < value:
			lo = mi
		else:
			hi = mi
	return -1
n = int(input())
a = input().split()
for i in range(n):
	a[i] = int(a[i])
print(solve(n, a))


import math
import sys

def main(arr):
	left = {}
	right = {}
	for e in arr:
		if e not in right:
			right[e] = 0
		right[e] += 1
	prefix = [arr[0]]
	for i in range(1, len(arr)):
		prefix.append(arr[i] + prefix[-1])
	s = prefix[-1]
	for i in range(len(arr)):
		if arr[i] not in left:
			left[arr[i]] = 0
		left[arr[i]] += 1
		right[arr[i]] -= 1
		a = prefix[i]
		b = s - prefix[i]
		if prefix[i] == s - prefix[i]:
			return 'YES'
		elif a > b:
			if (a - b) / 2 in left and left[(a - b) / 2] != 0:
				return 'YES'
		elif (b - a) / 2 in right and right[(b - a) / 2] != 0:
			return 'YES'
	return 'NO'
n = int(input())
arr = list(map(int, input().split()))
print(main(arr))


import sys
from itertools import accumulate

def solve():
	n = int(input())
	a = [int(i) for i in input().split()]
	S = sum(a)
	if S & 1:
		print('NO')
		return
	f_a = dict()
	l_a = dict()
	for i in range(n):
		if a[i] not in f_a:
			f_a[a[i]] = i
	for i in range(n - 1, -1, -1):
		if a[i] not in l_a:
			l_a[a[i]] = i
	ps = [0] + list(accumulate(a))
	S //= 2
	for k in range(1, n + 1):
		x = S - ps[k]
		if x == 0:
			print('YES')
			return
		elif x > 0:
			if x in l_a and k <= l_a[x]:
				print('YES')
				return
		else:
			x *= -1
			if x in f_a and f_a[x] < k:
				print('YES')
				return
	print('NO')
solve()


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

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

def map_string():
	return input().split()
n = int(input())
a = list_input()
k = sum(a)
cur = 0
s = set([0])
pref = [0]
for i in a:
	pref.append(pref[-1] + i)
	s.add(pref[-1])
for i in range(n):
	s.remove(pref[i])
	if k / 2 + a[i] in s:
		print('YES')
		break
else:
	a.reverse()
	cur = 0
	s = set([0])
	pref = [0]
	for i in a:
		pref.append(pref[-1] + i)
		s.add(pref[-1])
	for i in range(n):
		s.remove(pref[i])
		if k / 2 + a[i] in s:
			print('YES')
			break
	else:
		print('NO')


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

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

def pt(x):
	print(x)

def ip():
	return input()

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

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

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

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

def bin(x):
	return '{0:b}'.format(x)

def listring(l):
	return ' '.join([str(x) for x in l])

def ptlist(l):
	print(' '.join([str(x) for x in l]))
n = it()
a = lt()
k = 0
left = 0
right = sum(a)
bl = False
dict = {}
for i in range(n):
	if a[i] in dict:
		(ma, mi) = dict[a[i]]
		dict[a[i]] = (max(ma, i), min(mi, i))
	else:
		dict[a[i]] = (i, i)
while k < n and (not bl):
	if right == left:
		bl = True
	elif right > left:
		x = (right - left) / 2
		if x == int(x) and int(x) in dict and (dict[int(x)][0] >= k):
			bl = True
		else:
			right -= a[k]
			left += a[k]
			k += 1
	else:
		x = (left - right) / 2
		if x == int(x) and int(x) in dict and (dict[int(x)][1] <= k - 1):
			bl = True
		else:
			right -= a[k]
			left += a[k]
			k += 1
if bl:
	pt('YES')
else:
	pt('NO')


import sys

class BIT_RSQ(object):
	__slots__ = ['nodes', 'size']

	def __init__(self, size: int):
		self.nodes = [0] * (size + 1)
		self.size = size + 1

	def add(self, index: int, value: int):
		while index < self.size:
			self.nodes[index] += value
			index += index & -index

	def sum(self, right: int):
		result = 0
		while right:
			result += self.nodes[right]
			right -= right & -right
		return result

	def lower_bound(self, value: int):
		(k, result) = (1 << self.size.bit_length() - 1, 0)
		while k:
			if k + result < self.size and self.nodes[k + result] < value:
				value -= self.nodes[k + result]
				result += k
			k >>= 1
		return result + 1
n = int(input())
a = list(map(int, input().split()))
total = sum(a)
if total & 1:
	print('NO')
	exit()
half = total >> 1
for _ in range(2):
	bit = BIT_RSQ(n + 10)
	(l, r) = (0, total)
	for i in range(n):
		l += a[i]
		r -= a[i]
		try:
			if l == r or (half > r and bit.sum(bit.lower_bound(half - r)) == half - r):
				print('YES')
				exit()
		except Exception:
			pass
		bit.add(n - i + 5, a[i])
	a.reverse()
print('NO')


from functools import reduce

def solve():
	sum_ = a[:]
	for i in range(1, n):
		sum_[i] += sum_[i - 1]
	if sum_[n - 1] % 2:
		return False
	half = int(sum_[n - 1] / 2)
	st = set([0])
	for i in range(n):
		if sum_[i] >= half and sum_[i] - half in st:
			return True
		st.add(a[i])
	sum_ = a[:]
	for i in range(n - 2, -1, -1):
		sum_[i] += sum_[i + 1]
	st = set([0])
	for i in range(n - 1, -1, -1):
		if sum_[i] >= half and sum_[i] - half in st:
			return True
		st.add(a[i])
	return False
while True:
	try:
		n = int(input())
	except:
		break
	a = [int(x) for x in input().split(' ')]
	print('YES' if solve() else 'NO')


def process(A):
	S = sum(A)
	d1 = {}
	for x in A:
		if x not in d1:
			d1[x] = 0
		d1[x] += 1
	if S % 2 == 1:
		return 'NO'
	S1 = 0
	d2 = set([])
	for x in A:
		S1 += x
		d1[x] -= 1
		d2.add(x)
		y = S1 - S // 2
		if y == 0:
			return 'YES'
		if y in d2:
			return 'YES'
		y2 = S // 2 - S1
		if y2 in d1 and d1[y2] > 0:
			return 'YES'
	return 'NO'
n = int(input())
A = [int(x) for x in input().split()]
print(process(A))


def func():
	n = int(input())
	array = []
	sum = 0
	for (index, number) in enumerate(input().split()):
		num = int(number)
		array.append(num)
		sum += num
	if sum % 1 == 1:
		print('NO')
		return
	setn = set()
	sumSub = 0
	indexdict = {}
	for (indexm, number) in enumerate(array):
		sumSub += number
		sum2 = sumSub * 2 - sum
		if sum2 % 2 == 1:
			continue
		sum2 /= 2
		setn.add(sum2)
		indexdict[sum2] = indexm
	i = 0
	if 0 in setn:
		print('YES')
		return
	while i < n:
		num = array[i]
		if num in setn and num in indexdict and (i < indexdict[num]):
			print('YES')
			return
		if -num in setn and -num in indexdict and (i > indexdict[-num]):
			print('YES')
			return
		i += 1
	print('NO')
func()


import sys
n = int(input())
a = list(map(int, input().split()))
(lt, rt) = (0, sum(a))
cur = set()
cur.add(0)
ans = False
for i in range(n - 1):
	cur.add(2 * a[i])
	lt += a[i]
	rt -= a[i]
	if lt - rt in cur:
		ans = True
(lt, rt) = (sum(a), 0)
cur = set()
cur.add(0)
for i in range(n - 1, -1, -1):
	cur.add(2 * a[i])
	lt -= a[i]
	rt += a[i]
	if rt - lt in cur:
		ans = True
print('YES' if ans else 'NO')


import sys
from bisect import bisect_left, bisect_right

def find(arr, x):
	i1 = bisect_left(arr, x)
	i2 = bisect_right(arr, x)
	if i1 < len(arr) and arr[i1] == x:
		return (i1, i2 - 1)
	else:
		return -1
n = int(input())
arr = [(i, int(x)) for (i, x) in enumerate(input().split())]
cum = []
for i in range(n):
	if i == 0:
		cum.append(arr[i][1])
	else:
		cum.append(cum[i - 1] + arr[i][1])
arr.sort(key=lambda a: a[1])
values = [a[1] for a in arr]
for i in range(n):
	a = cum[i]
	b = cum[n - 1] - cum[i]
	diff = a - b
	if diff == 0:
		print('YES')
		exit()
	elif diff % 2 != 0:
		break
	else:
		diff //= 2
	idx = find(values, abs(diff))
	if idx != -1 and (diff > 0 and arr[idx[0]][0] <= i or (diff < 0 and arr[idx[1]][0] > i)):
		print('YES')
		exit()
print('NO')


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n,) = I()
a = I()
total = sum(a)
ans = 'NO'
if total % 2:
	print(ans)
	exit()
s = set()
s.add(0)
left = 0
for i in range(n):
	s.add(a[i])
	left += a[i]
	right = total - left
	mid = left - right
	if mid % 2:
		continue
	if mid // 2 in s and len(s) > 2:
		ans = 'YES'
		break
s = set()
s.add(0)
right = 0
for i in range(n - 1, -1, -1):
	s.add(a[i])
	right += a[i]
	left = total - right
	mid = right - left
	if mid % 2:
		continue
	if mid // 2 in s and len(s) > 1:
		ans = 'YES'
		break
print(ans)


import sys
import os
from io import BytesIO, IOBase

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

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

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

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

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

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

def ddi():
	return defaultdict(int)

def ddl():
	return defaultdict(list)

def ddd():
	return defaultdict(defaultdict(int))
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 gcd, pi, inf
from bisect import bisect_left as bl
from heapq import *

def is_present(a, v):
	idx = bl(a, v)
	return idx < len(a) and a[idx] == v

def solve():
	n = ii()
	a = li()
	d = ddl()
	sorted_list = list(set(a))
	sorted_list.sort()
	a = [0] + a + [0]
	n = len(a)
	pref = [0 for i in range(n)]
	suff = [0 for i in range(n)]
	for i in range(n):
		pref[i] = (pref[i - 1] if i else 0) + a[i]
		if a[i] not in d:
			d[a[i]].extend([i, -1])
	for i in range(n - 1, -1, -1):
		suff[i] = (suff[i + 1] if i < n - 1 else 0) + a[i]
		if d[a[i]][1] == -1:
			d[a[i]][1] = i
	for i in range(1, n):
		(p_sum, s_sum) = (pref[i - 1], suff[i])
		if p_sum == s_sum:
			print('YES')
			return
		to_find = []
		if p_sum > s_sum:
			tmp = p_sum - s_sum
			if not tmp & 1:
				to_find = [tmp // 2]
			for v in to_find:
				if is_present(sorted_list, v):
					(l, r) = d[v]
					if l <= i - 1:
						print('YES')
						return
		else:
			tmp = s_sum - p_sum
			if not tmp & 1:
				to_find = [tmp // 2]
			for v in to_find:
				if is_present(sorted_list, v):
					(l, r) = d[v]
					if r >= i:
						print('YES')
						return
	print('NO')
	return
solve()


n = int(input())
a = list(map(int, input().split()))
s = sum(a)

def solve(a):
	rtn = False
	tmp = 0
	dic = {}
	for i in range(n):
		tmp += a[i]
		dic[a[i]] = True
		if tmp == s // 2:
			rtn = True
			break
		elif s // 2 < tmp and tmp - s // 2 in dic:
			rtn = True
			break
	return rtn
if n == 1 or s % 2 == 1:
	print('NO')
elif solve(a) or solve(list(reversed(a))):
	print('YES')
else:
	print('NO')


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

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

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

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

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
a = array()
tot = sum(a)
C = Counter(a)
cur = defaultdict(int)
cur[a[0]] += 1
s1 = 0
ok = False
for i in range(n):
	s2 = tot - s1
	dif = abs(s2 - s1)
	if s1 == s2 and s1 != 0:
		ok = True
		break
	if s1 > s2 and cur[dif // 2] > 0 and (not dif % 2):
		ok = True
		break
	if s2 > s1 and C[dif // 2] - cur[dif // 2] > 0 and (not dif % 2):
		ok = True
		break
	cur[a[i]] += 1
	s1 += a[i]
if ok:
	print('YES')
else:
	print('NO')


from sys import stdin
from collections import defaultdict as dd
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
tot = sum(a)
curs = 0
encntrd = dd(lambda : 0)
flg = False
if tot % 2 == 0:
	tot //= 2
	for i in range(n):
		curs += a[i]
		encntrd[a[i]] = 1
		if encntrd[curs - tot] or curs == tot:
			flg = True
	curs = 0
	encntrd = dd(lambda : 0)
	for i in range(n - 1, -1, -1):
		curs += a[i]
		encntrd[a[i]] = 1
		if encntrd[curs - tot] or curs == tot:
			flg = True
if flg:
	print('YES')
else:
	print('NO')


import sys
n = int(input())
a = [int(i) for i in input().split()]
total = sum(a)
if total % 2 == 1:
	print('NO')
	sys.exit()
part_sum = total // 2
seen = set([0])
sum_so_far = 0
for x in a:
	sum_so_far += x
	seen.add(x)
	if sum_so_far - part_sum in seen:
		print('YES')
		sys.exit()
seen = set([0])
sum_so_far = 0
for x in a[::-1]:
	sum_so_far += x
	seen.add(x)
	if sum_so_far - part_sum in seen:
		print('YES')
		sys.exit()
print('NO')


n = int(input())
a = list(map(int, input().split()))
rev_a = a[::-1]

def main():
	bag = set()
	target = sum(a) / 2
	s = 0
	for i in a:
		bag.add(i)
		s += i
		if s == target:
			print('YES')
			return
		if s > target and s - target in bag:
			print('YES')
			return
	bag = set()
	s = 0
	for i in rev_a:
		bag.add(i)
		s += i
		if s == target:
			print('YES')
			return
		if s > target and s - target in bag:
			print('YES')
			return
	print('NO')
main()


n = int(input())
l = [int(i) for i in input().split()]
tot = sum(l)
if tot & 1:
	print('NO')
	exit()
sm = 0
mid = tot // 2
for i in l:
	sm += i
	if sm == tot - sm:
		print('YES')
		exit()
from collections import defaultdict

def check(l):
	d = defaultdict(int)
	sm = 0
	for i in range(n - 1):
		d[l[i]] += 1
		sm += l[i]
		add = l[i + 1]
		curr = sm + add
		rem = tot - curr
		if d[mid - rem]:
			print('YES')
			exit()
if check(l):
	pass
l = l[::-1]
if check(l):
	pass
print('NO')


def possible(a):
	if len(a) == 1:
		return False
	if len(a) == 2:
		return a[0] == a[1]
	total = sum(a)
	vals = set([a[0]])
	running = a[0]
	for el in a[1:]:
		running += el
		vals.add(el)
		if running == total - running:
			return True
		if (running - (total - running)) % 2 == 0 and (running - (total - running)) // 2 in vals:
			return True
	return False
n = int(input())
a = list(map(int, input().split()))
if possible(a) or possible(a[::-1]):
	print('YES')
else:
	print('NO')


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
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')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=300006, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

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

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
n = int(input())
l = list(map(int, input().split()))
su = sum(l)
if su % 2 != 0:
	print('NO')
	sys.exit(0)
su //= 2
tr = 0
done = set()
for i in range(n):
	done.add(l[i])
	tr += l[i]
	if tr - su in done:
		print('YES')
		sys.exit(0)
tr = 0
done = set()
for i in range(n - 1, -1, -1):
	done.add(l[i])
	tr += l[i]
	if tr - su in done:
		print('YES')
		sys.exit(0)
print('NO')


def f(aa, s):
	d = {a: i for (i, a) in enumerate(aa)}
	for (i, a) in enumerate(aa):
		if s in d and i <= d[s]:
			return True
		s -= a
		if s <= 0:
			break
	return not s
n = int(input())
aa = list(map(int, input().split()))
(s, res) = (sum(aa), False)
if not s & 1 and n > 1:
	res = f(aa, s // 2)
	if not res:
		aa.reverse()
		res = f(aa, s // 2)
print(('NO', 'YES')[res])


n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print('NO')
	exit(0)
p = 0
left = dict()
right = dict()
s = 0
for i in a:
	right[i] = right.get(i, 0) + 1
	s += i
if s % 2 != 0:
	print('NO')
	exit(0)
s //= 2
for i in range(n + 1):
	if right.get(s - p, 0) > 0 or left.get(p - s, 0) > 0:
		print('YES')
		exit(0)
	if i < n:
		p += a[i]
		right[a[i]] -= 1
		left[a[i]] = left.get(a[i], 0) + 1
print('NO')


def verifica(l, r, p):
	global vetor_aux
	while l <= r:
		meio = l + r >> 1
		if vetor_aux[meio] == p:
			return True
		if vetor_aux[meio] < p:
			l = meio + 1
		else:
			r = meio - 1
	return False
n = int(input())
vetor = list(map(int, input().split()))
vetor = [0] + vetor
vetor_aux = [0] * len(vetor)
for i in range(1, n + 1):
	vetor_aux[i] = vetor_aux[i - 1] + vetor[i]
if vetor_aux[n] & 1:
	print('NO')
	exit()
for i in range(1, n + 1):
	if verifica(i + 1, n, vetor_aux[n] / 2 + vetor[i]):
		print('YES')
		exit()
for i in reversed(range(n + 1)):
	if verifica(1, i - 1, vetor_aux[n] / 2 - vetor[i]):
		print('YES')
		exit()
print('NO')


def bs(a, be, en, v):
	if be + 1 >= en:
		return False
	while be + 1 < en:
		mid = (be + en) // 2
		if a[mid] == v:
			return True
		elif a[mid] < v:
			be = mid
		else:
			en = mid
	if a[be] == v:
		return True
	return False

def solve(inp, ps, n):
	su = ps[-1]
	if su % 2:
		return False
	su //= 2
	if bs(ps, 0, n, su):
		return True
	for i in range(n):
		if bs(ps, i, n, su + inp[i]):
			return True
	for i in range(n):
		if bs(ps, 0, i, su - inp[i]):
			return True
	return False
n = int(input())
inp = list(map(int, input().split()))
ps = [0] * n
for i in range(n):
	ps[i] = ps[i - 1] + inp[i]
print('YES' if solve(inp, ps, n) else 'NO')


from sys import stdin
n = int(stdin.readline())
arr = [int(x) for x in stdin.readline().split()]
s = sum(arr)
if s % 2 == 1:
	print('NO')
else:
	goal = s // 2
	s = 0
	e = {}
	e2 = set()
	for x in arr:
		if x in e:
			e[x] += 1
		else:
			e[x] = 1
	if goal in e:
		print('YES')
	else:
		valid = False
		for x in arr:
			s += x
			e2.add(x)
			e[x] -= 1
			if e[x] == 0:
				del e[x]
			if goal - s in e:
				valid = True
				break
			if s - goal in e2:
				valid = True
				break
		if valid:
			print('YES')
		else:
			print('NO')


import sys
from bisect import bisect_left as lb
from collections import deque
from queue import PriorityQueue as pq
from math import *
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
mod = 10 ** 9 + 7
n = ii()
a = il()
s = sum(a)
s1 = s
fl = 0
if s1 % 2 == 1:
	fl = 1
elif a[0] == s1 // 2 or a[-1] == s1 // 2:
	fl = 0
else:
	fl = 1
	for j in range(2):
		d = {}
		t = 0
		for i in range(n):
			d[a[i]] = True
			t += a[i]
			if d.get(t - s1 // 2):
				fl = 0
				break
		if fl == 0:
			break
		a.reverse()
if fl:
	print('NO')
else:
	print('YES')


NO = 'NO'
YES = 'YES'
n = int(input())
if n == 1:
	print(NO)
	exit()
A = list(map(int, input().split()))
if n <= 2:
	if A[0] == A[1]:
		print(YES)
		exit()
	else:
		print(NO)
		exit()
s = sum(A)
if s % 2 == 1:
	print(NO)
	exit()
p = s // 2
o_list = set(A[:2])
o_sum = sum(A[:2])
o_max = max(o_list)
for x in range(2, n):
	o_list.add(A[x])
	o_sum = o_sum + A[x]
	o_max = A[x] if o_max < A[x] else o_max
	if o_sum - p in o_list:
		print(YES)
		exit()
A.reverse()
o_list = set(A[:2])
o_sum = sum(A[:2])
o_max = max(o_list)
for x in range(2, n):
	o_list.add(A[x])
	o_sum = o_sum + A[x]
	o_max = A[x] if o_max < A[x] else o_max
	if o_sum - p in o_list:
		print(YES)
		exit()
print(NO)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
arr = list(map(int, input().split()))
dict1 = {}
dict2 = {}
s = sum(arr)
for i in range(n):
	if arr[i] not in dict2.keys():
		dict2[arr[i]] = 1
	else:
		dict2[arr[i]] += 1
x = 0
if s % 2 != 0:
	print('NO')
else:
	ans = False
	for i in range(n):
		if arr[i] not in dict1.keys():
			dict1[arr[i]] = 1
		else:
			dict1[arr[i]] += 1
		x += arr[i]
		dict2[arr[i]] -= 1
		if x == s // 2:
			ans = True
			break
		elif x < s // 2:
			y = s // 2 - x
			if y in dict2.keys() and dict2[y] > 0:
				dict2[y] -= 1
				ans = True
				break
		else:
			y = x - s // 2
			if y in dict1.keys() and dict1[y] > 0:
				dict1[y] -= 1
				ans = True
				break
	if ans:
		print('YES')
	else:
		print('NO')


from collections import Counter
n = int(input())
a = list(map(int, input().split(' ')))
total = sum(a)
if total % 2 == 1:
	print('NO')
else:
	target = total // 2
	left = 0
	to_add = Counter(a)
	to_del = Counter([])
	found = False
	for i in range(n):
		if left < target:
			need = target - left
			if need in to_add:
				found = True
				break
		if left == target:
			found = True
			break
		if left > target:
			extra = left - target
			if extra in to_del:
				found = True
				break
		to_add[a[i]] -= 1
		if to_add[a[i]] == 0:
			del to_add[a[i]]
		if not a[i] in to_del:
			to_del[a[i]] = 1
		else:
			to_del[a[i]] += 1
		left += a[i]
	print('YES' if found else 'NO')