#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define LagaKar ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define fi first
#define se second
#define precise(ans) cout<<fixed<<setprecision(15)<<ans
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define sz(x) ((ll)(x).size())
#define all(x) x.begin(), x.end()
#define PI 3.1415926535897932384626
#define MOD 1000000007
#define MOD1 998244353
typedef long long ll; typedef unsigned long long ull; typedef long double lld; typedef pair<ll, ll> pii; typedef pair<ll, ll> pl; typedef vector<ll> vi; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<pii> vpii; typedef vector<pl> vpl; template <typename T> using prq_mx = priority_queue<T>; template <typename T> using prq_mn = priority_queue<T, vector<T>, greater<T>>;
const double eps = 1e-9; const ll INF = (ll) 1e9; const ll inf64 = 2e18; const ll INF64 = 9e18;
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _prll(x); cerr << endl;
#else
#define debug(x)
#endif
void _prll(ll t) {cerr << t;} void _print(ll t) {cerr << t;} void _prll(string t) {cerr << t;} void _prll(char t) {cerr << t;} void _prll(lld t) {cerr << t;} void _prll(double t) {cerr << t;} void _prll(ull t) {cerr << t;} template <class T, class V> void _prll(pair <T, V> p); template <class T> void _prll(vector <T> v); template <class T> void _prll(set <T> v); template <class T, class V> void _prll(map <T, V> v); template <class T> void _prll(multiset <T> v); template <class T, class V> void _prll(pair <T, V> p) {cerr << "{"; _prll(p.fi); cerr << ","; _prll(p.se); cerr << "}";} template <class T> void _prll(vector <T> v) {cerr << "[ "; for (T i : v) {_prll(i); cerr << " ";} cerr << "]";} template <class T> void _prll(set <T> v) {cerr << "[ "; for (T i : v) {_prll(i); cerr << " ";} cerr << "]";} template <class T> void _prll(multiset <T> v) {cerr << "[ "; for (T i : v) {_prll(i); cerr << " ";} cerr << "]";} template <class T, class V> void _prll(map <T, V> v) {cerr << "[ "; for (auto i : v) {_prll(i); cerr << " ";} cerr << "]";}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//////////////////////////////////////////////////////////////////////////////////
void chal(){
ll n;
cin>>n;
vl aa(n);
ll sum=0;
fo(i,n){
cin>>aa[i];
sum+=aa[i];
}
if(sum%2!=0){
cout<<"NO"<<endl;
return;
}
multiset<ll> bb;
fo(i,n){
bb.insert(aa[i]);
}
ll sum2=0;
if(bb.find(sum/2)!=bb.end()){
cout<<"YES"<<endl;
return;
}
fo(i,n){
sum2+=aa[i];
bb.erase(bb.find(aa[i]));
if(sum2==(sum/2)){
cout<<"YES"<<endl;
return;
}else if(sum2<(sum/2)){
ll x=(sum/2)-sum2;
if(bb.find(x)!=bb.end()){
cout<<"YES"<<endl;
return;
}
}else{
break;
}
}
bb.clear();
fo(i,n)bb.insert(aa[i]);
sum2=0;
Fo(i,n-1,-1){
sum2+=aa[i];
bb.erase(bb.find(aa[i]));
if(sum2==(sum/2)){
cout<<"YES"<<endl;
return;
}else if(sum2<(sum/2)){
ll x=(sum/2)-sum2;
if(bb.find(x)!=bb.end()){
cout<<"YES"<<endl;
return;
}
}else{
break;
}
}
cout<<"NO"<<endl;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int32_t main() {
LagaKar;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); freopen("Error.txt", "w", stderr);
#endif
ll t; t = 1;
// cin >> t;
for (ll i = 1; i <= t; i++) {
chal();
} return 0;
}
1728A - Colored Balls Revisited | 276B - Little Girl and Game |
1181A - Chunga-Changa | 1728C - Digital Logarithm |
1728D - Letter Picking | 792B - Counting-out Rhyme |
1195A - Drinks Choosing | 5D - Follow Traffic Rules |
1272A - Three Friends | 1632D - New Year Concert |
1400D - Zigzags | 716C - Plus and Square Root |
412A - Poster | 844B - Rectangles |
1591A - Life of a Flower | 1398C - Good Subarrays |
629A - Far Relative’s Birthday Cake | 1166A - Silent Classroom |
1000B - Light It Up | 218B - Airport |
1463B - Find The Array | 1538C - Number of Pairs |
621B - Wet Shark and Bishops | 476B - Dreamoon and WiFi |
152C - Pocket Book | 1681D - Required Length |
1725D - Deducing Sortability | 1501A - Alexey and Train |
721B - Passwords | 1263D - Secret Passwords |