#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define out freopen("output.txt", "w", stdout);
#define in freopen("input.txt", "r", stdin);
#define pub push_back
#define pob pop_back
#define infinity 1000000010
#define LL long long int
#define Pi acos(-1)
#define SZ 100010

///int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
///int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
///int col[4] = {1, 0, -1, 0};
///int row[4] = {0, 1, 0, -1};

using namespace std;

LL arr[2 * SZ];

bool comp(const LL &a, const LL &b)
{
    return a > b;
}

int main()
{
    int n, q, i, a, b;
    LL ans = 0;
    cin >> n >> q;
    for(i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n, comp);
    sort(arr, arr + (n / 2) + n % 2);
    for(i = 1; i < n; i++)
        arr[i] += arr[i - 1];
    for(i = 0; i < q; i++)
    {
        cin >> a >> b;
        ans += arr[b - 1] - arr[a - 2];
    }
    printf("%I64d\n", ans);
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define out freopen("output.txt", "w", stdout);
#define in freopen("input.txt", "r", stdin);
#define pub push_back
#define pob pop_back
#define infinity 1000000010
#define LL long long int
#define Pi acos(-1)
#define SZ 100010

///int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
///int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
///int col[4] = {1, 0, -1, 0};
///int row[4] = {0, 1, 0, -1};

using namespace std;

int arr[2 * SZ];

bool comp(const int &a, const int &b)
{
    return a > b;
}

int main()
{
    int n, q, i, a, b;
    while(cin >> n >> q)
        {
            int ans = 0;
            for(i = 0; i < n; i++)
                cin >> arr[i];
            sort(arr, arr + n, comp);
            sort(arr, arr + (n / 2) + (n % 2));
            for(i = 1; i < n; i++)
                {
                    arr[i] += arr[i - 1];
                }
            for(i = 0; i < q; i++)
                {
                    cin >> a >> b;
                    ans += arr[b - 1] - arr[a - 2];
                }
            cout << ans << endl;
        }
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define out freopen("output.txt", "w", stdout);
#define in freopen("input.txt", "r", stdin);
#define pub push_back
#define pob pop_back
#define infinity 1000000010
#define LL long long int
#define Pi acos(-1)
#define SZ 100010

///int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
///int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
///int col[4] = {1, 0, -1, 0};
///int row[4] = {0, 1, 0, -1};

using namespace std;

LL arr[2 * SZ];

bool comp(const LL &a, const LL &b)
{
    return a > b;
}

int main()
{
    int n, q, i, a, b;
    while(cin >> n >> q)
        {
            LL ans = 0;
            for(i = 0; i < n; i++)
                cin >> arr[i];
            sort(arr, arr + n, comp);
            sort(arr, arr + (n / 2) + (n % 2));
            for(i = 1; i < n; i++)
                {
                    arr[i] += arr[i - 1];
                    cout << arr[i] << endl;
                }
            for(i = 0; i < q; i++)
                {
                    cin >> a >> b;
                    ans += arr[b - 1] - arr[a - 2];
                }
            cout << ans << endl;
        }
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

#define out freopen("output.txt", "w", stdout);
#define in freopen("input.txt", "r", stdin);
#define pub push_back
#define pob pop_back
#define infinity 1000000010
#define LL long long int
#define Pi acos(-1)
#define SZ 100010

///int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
///int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
///int col[4] = {1, 0, -1, 0};
///int row[4] = {0, 1, 0, -1};

using namespace std;

LL arr[2 * SZ];
int tem[2 * SZ];

int main()
{
    int a, b, n, q, i;
    LL ans = 0;
    cin >> n >> q;
    for(i = 1; i <= n; i++)
        cin >> arr[i];
    for(i = 0; i < q; i++)
    {
        cin >> a >> b;
        tem[a]++;
        tem[b + 1]--;
    }
    for(i = 2; i <= n; i++)
        tem[i] += tem[i - 1];
    sort(tem, tem + n + 1);
    sort(arr, arr + n + 1);
    for(i = n; i > 0; i--)
        ans += (tem[i] * arr[i]);
    cout << ans;
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int a[300000],b[300000];

int main()
{
	int n,q1,q2,counter=0,sum=0,n2;
	cin>>n>>n2;
	for (int i=1;i<=n;i++)
		cin>>a[i];

	sort(a,a+300000,greater<int>());
	for (int i=1;i<=n2;i++)
	{
		cin>>q1>>q2;
		for (int i=q1;i<=q2;i++)
			++b[i];
	}
	sort(b,b+300000,greater<int>());
	n=0;
	while (n==0)
	{
		if (b[counter]==0) n=1;
		else
		{
			sum += b[counter] * a[counter];
			++counter;
		}
	}
	cout<<sum<<endl;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int a[200010],b[200010];

int main()
{
	int n,q1,q2,counter=0,sum=0,n2;
	cin>>n>>n2;
	for (int i=1;i<=n;++i)
		cin>>a[i];
	sort(a,a+200010,greater<int>());
	for (int i=1;i<=n2;++i)
	{
		cin>>q1>>q2;
		for (int ff=q1;ff<=q2;++ff)
			++b[ff];
	}
	sort(b,b+200010,greater<int>());
	n=0;
	while (n==0)
	{
		if (b[counter]==0) n=1;
		else
		{
			sum += b[counter] * a[counter];
			++counter;
		}
		if (counter==200009) n=1;
	}
	cout<<sum<<endl;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int a[200010],b[200010];

int main()
{
	int n,q1,q2,counter=0,sum=0,n2;
	cin>>n>>n2;
	for (int i=1;i<=n;i++)
		cin>>a[i];
	sort(a,a+n+10,greater<int>());
	for (int i=1;i<=n2;i++)
	{
		cin>>q1>>q2;
		for (int i=q1;i<=q2;i++)
			++b[i];
	}
	sort(b,b+n2+10,greater<int>());
	n=0;
	while (n==0)
	{
		if (b[counter]==0) n=1;
		else
		{
			sum += b[counter] * a[counter];
			++counter;
		}
		if (counter==200009) n=1;
	}
	cout<<sum<<endl;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int a[200010],b[200010],c[200010],m=0;

int main()
{
	long long int n,q1,q2,counter=0,sum=0,n2;
	cin>>n>>n2;
	for (int i=0;i<n;++i)
		cin>>a[i];
	sort(a,a+200010,greater<int>());
	for (int i=0;i<n2;++i)
	{
		cin>>q1>>q2;
		b[q1]++;
		b[q2+1]--;
	}
	for (int i=1;i<200010;++i)
	{
		m += b[i];
		c[i] = m;
	}
	sort(c,c+200010,greater<int>());
	n=0;
	while (n==0)
	{
		if (a[counter]==0) n=1;
		else
		{
			sum += c[counter] * a[counter];
			counter++;
		}
		if (counter == 200010) n=1;
	}
	cout<<sum<<endl;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int a[200010],b[200010];

int main()
{
	int n,q1,q2,counter=0,sum=0,n2;
	cin>>n>>n2;
	for (int i=1;i<=n;i++)
		cin>>a[i];
	sort(a,a+200010,greater<int>());
	for (int i=1;i<=n2;i++)
	{
		cin>>q1>>q2;
		for (int i=q1;i<=q2;i++)
			++b[i];
	}
	sort(b,b+200010,greater<int>());
	n=0;
	while (n==0)
	{
		if (b[counter]==0) n=1;
		else
		{
			sum += b[counter] * a[counter];
			++counter;
		}
		if (counter==200009) n=1;
	}
	cout<<sum<<endl;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int a[200010],b[200010],c[200010],m=0;

int main()
{
	long long int n,q1,q2,counter=0,sum=0,n2;
	cin>>n>>n2;
	for (int i=0;i<n;++i)
		cin>>a[i];
	sort(a,a+200010,greater<int>());
	for (int i=0;i<n2;++i)
	{
		cin>>q1>>q2;
		b[q1]++;
		b[q2+1]--;
	}
	for (int i=1;i<200010;++i)
	{
		m += b[i];
		c[i] = m;
	}
	sort(c,c+200010,greater<int>());
	n=0;
	for (int i=0;i<200010;i++)
		sum += c[i] * a[i];
	cout<<sum<<endl;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

int a[200010],b[200010],c[200010],m=0;

int main()
{
	int n,q1,q2,counter=0,sum=0,n2;
	cin>>n>>n2;
	for (int i=0;i<n;++i)
		cin>>a[i];
	sort(a,a+200010,greater<int>());
	for (int i=0;i<n2;++i)
	{
		cin>>q1>>q2;
		b[q1]++;
		b[q2+1]--;
	}
	for (int i=1;i<200010;++i)
	{
		m += b[i];
		c[i] = m;
	}

	sort(c,c+200010,greater<int>());
	n=0;
	while (n==0)
	{
		if (c[counter]==0 || a[counter]==0) n=1;
		else
		{
			sum += c[counter] * a[counter];
			++counter;
		}
		if (counter==200009) n=1;
	}
	cout<<sum<<endl;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <functional>

using namespace std;

long long int a[200010],b[200010],c[200010],m=0;

int main()
{
	long long int n,q1,q2,counter=0,sum=0,n2;
	cin>>n>>n2;
	for (int i=0;i<n;++i)
		cin>>a[i];
	sort(a,a+200010,greater<int>());
	for (int i=0;i<n2;++i)
	{
		cin>>q1>>q2;
		b[q1]++;
		b[q2+1]--;
	}
	for (int i=1;i<200010;++i)
	{
		m += b[i];
		c[i] = m;
	}
	sort(c,c+200010,greater<int>());
	n=0;
	for (int i=0;i<200010;i++)
		sum += c[i] * a[i];
	cout<<sum<<endl;
}


#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int a[N + 1];
main() {
    int n = readInt();
    int s = 0;
    for (int i = 1; i <= n; i++) {
        a[i] = readInt();
        s += a[i];
    }
    sort(a + 1, a + n + 1);
    for (int i = 2; i <= n; i++) {
        if (a[i] > 2 * a[i - 1]) {
            puts("NO");
            return 0;
        }
    }
    int s1 = 0, s2 = 0;
    for (int i = n; i >= 1; i--) {
        if (s1 >= s2) {
            s2 += a[i];
        } else {
            s1 += a[i];
        }
    }
    puts((s1 == s2) ? "YES" : "NO");
}


#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int a[N + 1];
main() {
    int n = readInt();
    int s = 0;
    for (int i = 1; i <= n; i++) {
        a[i] = readInt();
    }
    sort(a + 1, a + n + 1);
    int s1 = 0, s2 = 0;
    for (int i = n; i >= 1; i--) {
        if (s1 >= s2) {
            s2 += a[i];
        } else {
            s1 += a[i];
        }
    }
    puts((s1 == s2) ? "YES" : "NO");
}


#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int a[N + 1];
main() {
    int n = readInt();
    int s = 0;
    for (int i = 1; i <= n; i++) {
        a[i] = readInt();
        s += a[i];
    }
    int x = 0;
    for (int i = 1; i <= n; i++) {
        x += a[i];
        s -= a[i];
        if (x % 2 == s % 2) {
            puts("YES");
            return 0;
        }
    }
    puts("NO");
}


#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int a[N + 1];
main() {
    int n = readInt();
    for (int i = 1; i <= n; i++) {
        a[i] = readInt();
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i < n; i++) {
        a[i + 1] -= a[i];
    }
    puts((a[n] == 0) ? "YES" : "NO");
}


#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int a[N + 1];
main() {
    int n = readInt();
    int s = 0;
    for (int i = 1; i <= n; i++) {
        a[i] = readInt();
        s += a[i];
    }
    puts((s % 2 == 0) ? "YES" : "NO");
}


#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int a[N + 1];
main() {
    int n = readInt();
    int s = 0;
    for (int i = 1; i <= n; i++) {
        a[i] = readInt();
        s += a[i];
    }
    if (s % 2 == 1) {
        puts("NO");
        return 0;
    }
    if (n == 2) {
        if (a[1] == a[2]) {
            puts("YES");
        } else {
            puts("NO");
        }
        return 0;
    }
    sort(a + 1, a + n + 1);
    if (s - a[n] < a[n]) {
        puts("NO");
        return 0;
    }
    puts("YES");
}


#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
int a[N + 1];
main() {
    int n = readInt();
    map<int, int> mp;
    for (int i = 1; i <= n; i++) {
        a[i] = readInt();
        mp[a[i]]++;
    }
    for (auto it : mp) {
        if (it.second % 2 == 1) {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 2000000000ll
#define SIZE 100000ll
#define pb push_back

int32_t main()
{
    ifstream fin("input.txt",ios::in);
    ios_base::sync_with_stdio(false);
    cout<<setprecision(10);
    ll n;
    cin>>n;

    vector<ll> p;
    ll sum=0;

    for(ll i=0;i<n;i++)
    {
        ll x=0;
        cin>>x;
        sum+=x;
        p.pb(x);
    }
    if(n%2!=0)
    {
        p.pb(0);
        n++;
    }
    if(sum%2!=0)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    sort(p.begin(),p.end());
    if(n==2)
    {
        if(p[0]==p[1])
        {
            cout<<"YES"<<endl;
            return 0;
        }else
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    ll s=0;
    for(ll i=0;i<n;i+=2)
    {
            if(i!=n-2)
            {
                ll x = p[i+1]-p[i];
                p[i+1]=p[i];
                if(p[i+3]-p[i+2]>=x)
                {
                    //cout<<"D"<<endl;
                    p[i+3]-=x;
                }else
                {
                    int t=0;
                    x-=p[i+3]-p[i+2];
                    p[i+3]=p[i+2];
                    if(x%2==1) t=1;
                    x/=2;
                    p[i+3]-=x;
                    p[i+2]-=x;
                    p[i+2]-=t;
                }
                s+=p[i+1]+p[i];
            }else
            {
                if(p[n-2]-p[n-1]<=s)
                {
                    cout<<"YES"<<endl;
                    return 0;
                }
                cout<<"NO"<<endl;
                return 0;
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 2000000000ll
#define SIZE 100000ll
#define pb push_back

int32_t main()
{
    ifstream fin("input.txt",ios::in);
    ios_base::sync_with_stdio(false);
    cout<<setprecision(10);
    ll n;
    cin>>n;

    vector<ll> p;
    ll sum=0;

    for(ll i=0;i<n;i++)
    {
        ll x=0;
        cin>>x;
        sum+=x;
        p.pb(x);
    }
    if(n%2!=0)
    {
        p.pb(0);
        n++;
    }
    if(sum%2!=0)
    {
        cout<<"NO"<<endl;
        return 0;
    }else
    {
        for(ll i=0;i<n;i++)
        {
            p[i]-=p[i]%2;
        }
    }
    sort(p.begin(),p.end());
    if(n==2)
    {
        if(p[0]==p[1])
        {
            cout<<"YES"<<endl;
            return 0;
        }else
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    ll s=0;
    for(ll i=0;i<n;i+=2)
    {
        if(p[i+1]-p[i]<=s)
        {
            //cout<<1<<endl;
            s-=p[i+1]-p[i];
            p[i+1]=p[i];
            s+=p[i]+p[i+1];
        }else
        {
            //cout<<2<<endl;
            if(i!=n-2)
            {
                p[i+1]-=s;
                s=0;
                ll x = p[i+3]-p[i+2];
                p[i+1]=p[i];
                if(p[i+3]-p[i+2]>=x)
                {
                    p[i+3]-=x;
                }else
                {
                    x-=p[i+3]-p[i+2];
                    p[i+3]=p[i+2];
                    x/=2;
                    p[i+3]-=x;
                    p[i+2]-=x;
                    s+=p[i+2]+p[i+3];
                }
            }else
            {
                cout<<"NO"<<endl;
                return 0;
            }
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 2000000000ll
#define SIZE 100000ll
#define pb push_back

int32_t main()
{
    ifstream fin("input.txt",ios::in);
    ios_base::sync_with_stdio(false);
    cout<<setprecision(10);
    ll n;
    cin>>n;
    vector<ll> p;
    for(ll i=0;i<n;i++)
    {
        ll x=0;
        cin>>x;
        p.pb(x);
    }
    while(true)
    {
        vector<ll> pp;
        sort(p.begin(),p.end());
        ll i;
        for(i=p.size()-1;i>-1;i--)
        {
            if(i==0)
            {
                pp.pb(p[i]);
                break;
            }
            p[i]-=p[i-1];
            p[i-1]=0;
            if(p[i]!=0) pp.pb(p[i]);
            i--;
        }
        p.clear();
        for(ll i=0;i<pp.size();i++) p.pb(pp[i]);
        if(p.size()==0)
        {
            cout<<"YES"<<endl;
            return 0;
        }else if(p.size()==1)
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 2000000000ll
#define SIZE 100000ll
#define pb push_back

int32_t main()
{
    ifstream fin("input.txt",ios::in);
    ios_base::sync_with_stdio(false);
    cout<<setprecision(10);
    ll n;
    cin>>n;

    vector<ll> p;
    ll sum=0;

    for(ll i=0;i<n;i++)
    {
        ll x=0;
        cin>>x;
        sum+=x;
        p.pb(x);
    }
    sort(p.begin(),p.end());
    if(sum%2!=0||p[n-1]>sum-p[n-1])
    {
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 2000000000ll
#define SIZE 100000ll
#define pb push_back

int32_t main()
{
    ifstream fin("input.txt",ios::in);
    ios_base::sync_with_stdio(false);
    cout<<setprecision(10);
    ll n;
    cin>>n;

    vector<ll> p;
    ll sum=0;

    for(ll i=0;i<n;i++)
    {
        ll x=0;
        cin>>x;
        sum+=x;
        p.pb(x);
    }
    if(n%2!=0)
    {
        p.pb(0);
        n++;
    }
    if(sum%2!=0)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    sort(p.begin(),p.end());
    if(n==2)
    {
        if(p[0]==p[1])
        {
            cout<<"YES"<<endl;
            return 0;
        }else
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    ll s=0;
    for(ll i=0;i<n-2;i+=2)
    {
        ll x = p[i+1]-p[i];
        p[i+1]=p[i];
        if(p[i+3]-p[i+2]>=x)
        {
            p[i+3]-=x;
        }else
        {
            int t=0;
            x-=p[i+3]-p[i+2];
            p[i+3]=p[i+2];
            if(x%2==1) t=1;
            x/=2;
            p[i+3]-=x;
            p[i+2]-=x;
            p[i+2]-=t;
        }
        s+=p[i+1]+p[i];
    }
    if(p[n-1]-p[n-2]<=s) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 2000000000ll
#define SIZE 100000ll
#define pb push_back

int32_t main()
{
    ifstream fin("input.txt",ios::in);
    ios_base::sync_with_stdio(false);
    cout<<setprecision(10);
    ll n;
    cin>>n;

    vector<ll> p;
    ll sum=0;

    for(ll i=0;i<n;i++)
    {
        ll x=0;
        cin>>x;
        sum+=x;
        p.pb(x);
    }
    if(n%2!=0)
    {
        p.pb(0);
        n++;
    }
    if(sum%2!=0)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    sort(p.begin(),p.end());
    if(n==2)
    {
        if(p[0]==p[1])
        {
            cout<<"YES"<<endl;
            return 0;
        }else
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    ll s=0;
    for(ll i=0;i<n;i+=2)
    {
        if(p[i+1]-p[i]<=s)
        {
            //cout<<1<<endl;
            s-=p[i+1]-p[i];
            p[i+1]=p[i];
            s+=p[i]+p[i+1];
        }else
        {
            //cout<<2<<endl;
            if(i!=n-2)
            {
                p[i+1]-=s;
                s=0;
                ll x = p[i+1]-p[i];
                p[i+1]=p[i];
                if(p[i+3]-p[i+2]>=x)
                {
                    //cout<<"D"<<endl;
                    p[i+3]-=x;
                }else
                {
                    int t=0;
                    x-=p[i+3]-p[i+2];
                    p[i+3]=p[i+2];
                    if(x%2==1) t=1;
                    x/=2;
                    p[i+3]-=x;
                    p[i+2]-=x;
                    p[i+2]-=t;
                }
                s+=p[i+1]+p[i];
            }else
            {
                cout<<"NO"<<endl;
                return 0;
            }
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 2000000000ll
#define SIZE 100000ll
#define pb push_back

int32_t main()
{
    ifstream fin("input.txt",ios::in);
    ios_base::sync_with_stdio(false);
    cout<<setprecision(10);
    ll n;
    cin>>n;
    vector<ll> p;
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
        ll x=0;
        cin>>x;
        sum+=x;
        p.pb(x);
    }
    if(sum%2 != 0)
    {
        cout<<"NO"<<endl;
        return 0;
    }else
    {
        for(int i=0;i<n;i++)
        {
            p[i]-=p[i]%2;
        }
    }
    while(true)
    {
        vector<ll> pp;
        sort(p.begin(),p.end());
        ll i;
        for(i=p.size()-1;i>-1;i--)
        {
            if(i==0)
            {
                pp.pb(p[i]);
                break;
            }
            p[i]-=p[i-1];
            p[i-1]=0;
            if(p[i]!=0) pp.pb(p[i]);
            i--;
        }
        p.clear();
        for(ll i=0;i<pp.size();i++) p.pb(pp[i]);
        if(p.size()==0)
        {
            cout<<"YES"<<endl;
            return 0;
        }else if(p.size()==1)
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define INF 2000000000ll
#define SIZE 100000ll
#define pb push_back

int32_t main()
{
    ifstream fin("input.txt",ios::in);
    ios_base::sync_with_stdio(false);
    cout<<setprecision(10);
    ll n;
    cin>>n;

    vector<ll> p;
    ll sum=0;

    for(ll i=0;i<n;i++)
    {
        ll x=0;
        cin>>x;
        sum+=x;
        p.pb(x);
    }
    if(n%2!=0)
    {
        p.pb(0);
        n++;
    }
    if(sum%2!=0)
    {
        cout<<"NO"<<endl;
        return 0;
    }
    sort(p.begin(),p.end());
    if(n==2)
    {
        if(p[0]==p[1])
        {
            cout<<"YES"<<endl;
            return 0;
        }else
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    ll s=0;
    for(ll i=0;i<n;i+=2)
    {
        if(p[i+1]-p[i]<=s)
        {
            s-=p[i+1]-p[i];
            p[i+1]=p[i];
            s+=p[i]+p[i+1];
        }else
        {
            if(i!=n-2)
            {
                p[i+1]-=s;
                s=0;
                ll x = p[i+1]-p[i];
                p[i+1]=p[i];
                if(p[i+3]-p[i+2]>=x)
                {
                    p[i+3]-=x;
                }else
                {
                    int t=0;
                    x-=p[i+3]-p[i+2];
                    p[i+3]=p[i+2];
                    if(x%2==1) t=1;
                    x/=2;
                    p[i+3]-=x;
                    p[i+2]-=x;
                    p[i+2]-=t;
                    s+=p[i+2]+p[i+3];
                }
            }else
            {
                cout<<"NO"<<endl;
                return 0;
            }
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


#include <bits/stdc++.h>

#define forf(i, n) for (int i = 0; i < int(n); i++)
#define forb(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forn(i, l, r) for (int i = int(l); i < int(r); i++)
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define mp(x, y) make_pair((x), (y))
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
//#define x first
//#define y second

using namespace std;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
const int INF = int(1e9);

int arr[200005];

int main() {
    FastIO;
    int n;
    cin >> n;
    int sum=0;
    for (int i=0;i<n;i++){
        cin >> arr[i];
        sum += arr[i];
    }
    sum -= arr[n-1];
    sort(arr,arr+n);
    cout << ((arr[n-1] >= sum /2 && (sum + arr[n-1])%2==0) ? "YES" : "NO");
}


#include <bits/stdc++.h>

#define forf(i, n) for (int i = 0; i < int(n); i++)
#define forb(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forn(i, l, r) for (int i = int(l); i < int(r); i++)
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define mp(x, y) make_pair((x), (y))
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
//#define x first
//#define y second

using namespace std;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
const int INF = int(1e9);

ll arr[200005];

int main() {
    FastIO;
    ll n;
    cin >> n;
    ll sum=0;
    for (ll i=0;i<n;i++){
        cin >> arr[i];
        sum += arr[i];
    }
    sum -= arr[n-1];
    sort(arr,arr+n);
    cout << ((arr[n-1] >= sum /2 && (sum + arr[n-1])%2==0) ? "YES" : "NO");
}


#include <bits/stdc++.h>

#define forf(i, n) for (int i = 0; i < int(n); i++)
#define forb(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forn(i, l, r) for (int i = int(l); i < int(r); i++)
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define mp(x, y) make_pair((x), (y))
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
//#define x first
//#define y second

using namespace std;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
const int INF = int(1e9);

ll s[200005],n,sum;

bool findPartiion ()
{
    for (int i=n;i>=1;i--){
        int t = sum/2;
        for (int j=n;j>=1;j--){
            if (t>=s[j%n+1]){
                t -= s[j%n+1];
            }
        }
        if (t==0)return true;
    }
    return false;
}

int main() {
    FastIO;
    cin >> n;
    for (int i=1;i<=n;i++){
        cin >> s[i];
        sum+=s[i];
    }
    if(sum%2!=0)cout << "NO";
    else{
        if(findPartiion())cout << "YES";
        else cout << "NO";
    }

}


#include <bits/stdc++.h>

#define forf(i, n) for (int i = 0; i < int(n); i++)
#define forb(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forn(i, l, r) for (int i = int(l); i < int(r); i++)
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define mp(x, y) make_pair((x), (y))
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
//#define x first
//#define y second

using namespace std;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
const int INF = int(1e9);

ll arr[200005];

int main() {
    FastIO;
    ll n;
    cin >> n;
    ll sum=0;
    for (ll i=0;i<n;i++){
        cin >> arr[i];
        sum += arr[i];
    }
    sum -= arr[n-1];
    sort(arr,arr+n);
    cout << ((arr[n-1] <= sum && (sum + arr[n-1])%2==0) ? "YES" : "NO");
}


#include <bits/stdc++.h>

#define forf(i, n) for (int i = 0; i < int(n); i++)
#define forb(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forn(i, l, r) for (int i = int(l); i < int(r); i++)
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define mp(x, y) make_pair((x), (y))
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
//#define x first
//#define y second

using namespace std;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
const int INF = int(1e9);

int s[200005];
bool findPartiion (int arr[], int n)
{
    int sum = 0;
    int i, j;
    for (i = 0; i < n; i++)
        sum += arr[i];
    if (sum%2 != 0)
        return false;
    bool part[sum/2+1][n+1];
    for (i = 0; i <= n; i++)
        part[0][i] = true;
    for (i = 1; i <= sum/2; i++)
        part[i][0] = false;
    for (i = 1; i <= sum/2; i++)
    {
        for (j = 1; j <= n; j++)
        {
            part[i][j] = part[i][j-1];
            if (i >= arr[j-1])
                part[i][j] = part[i][j] || part[i - arr[j-1]][j-1];
        }
    }
    return part[sum/2][n];
}

int main() {
    FastIO;
    int n,k;
    cin >> n;
    int sum=0;
    for (int i=0;i<n;i++){
        cin >> s[i];
        sum+=s[i];
    }
    if(sum%2!=0)cout << "NO";
    else{
        if(findPartiion(s,n))cout << "YES";
        else cout << "NO";
    }

}


#include <bits/stdc++.h>

#define forf(i, n) for (int i = 0; i < int(n); i++)
#define forb(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forn(i, l, r) for (int i = int(l); i < int(r); i++)
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define mp(x, y) make_pair((x), (y))
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
//#define x first
//#define y second

using namespace std;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
const int INF = int(1e9);

ll arr[200005];

int main() {
    FastIO;
    ll n;
    cin >> n;
    ll sum=0;
    for (ll i=0;i<n;i++){
        cin >> arr[i];
        sum += arr[i];
    }
    sort(arr,arr+n);
    sum -= arr[n-1];
    cout << ((arr[n-1] <= sum && (sum + arr[n-1])%2==0) ? "YES" : "NO");
}


#include <bits/stdc++.h>

#define forf(i, n) for (int i = 0; i < int(n); i++)
#define forb(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forn(i, l, r) for (int i = int(l); i < int(r); i++)
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define mp(x, y) make_pair((x), (y))
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
//#define x first
//#define y second

using namespace std;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
const int INF = int(1e9);

ll arr[200005];

int main() {
    FastIO;
    ll n;
    cin >> n;
    ll sum=0;
    for (ll i=0;i<n;i++){
        cin >> arr[i];
        sum += arr[i];
    }
    sum -= arr[n-1];
    sort(arr,arr+n);
    cout << ((arr[n-1] <= sum /2 && (sum + arr[n-1])%2==0) ? "YES" : "NO");
}


#include <bits/stdc++.h>

#define forf(i, n) for (int i = 0; i < int(n); i++)
#define forb(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forn(i, l, r) for (int i = int(l); i < int(r); i++)
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define mp(x, y) make_pair((x), (y))
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
//#define x first
//#define y second

using namespace std;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
const int INF = int(1e9);

bool findPartiion (int arr[], int n)
{
    int sum = 0;
    int i, j;
    for (i = 0; i < n; i++)
        sum += arr[i];
    if (sum%2 != 0)
        return false;
    bool part[sum/2+1][n+1];
    for (i = 0; i <= n; i++)
        part[0][i] = true;
    for (i = 1; i <= sum/2; i++)
        part[i][0] = false;
    for (i = 1; i <= sum/2; i++)
    {
        for (j = 1; j <= n; j++)
        {
            part[i][j] = part[i][j-1];
            if (i >= arr[j-1])
                part[i][j] = part[i][j] || part[i - arr[j-1]][j-1];
        }
    }
    return part[sum/2][n];
}

int main() {
    FastIO;
    int n,k;
    cin >> n;
    int s[n+5];
    int sum=0;
    for (int i=0;i<n;i++){
        cin >> s[i];
        sum+=s[i];
    }
    if(sum%2!=0)cout << "NO";
    else{
        if(findPartiion(s,n))cout << "YES";
        else cout << "NO";
    }

}


#include <bits/stdc++.h>

#define forf(i, n) for (int i = 0; i < int(n); i++)
#define forb(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forn(i, l, r) for (int i = int(l); i < int(r); i++)
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define mp(x, y) make_pair((x), (y))
#define FastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
//#define x first
//#define y second

using namespace std;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
const int INF = int(1e9);

bool findPartiion (const ll arr[], ll n)
{
    ll sum = 0;
    ll i, j;
    for (i = 0; i < n; i++)
        sum += arr[i];
    if (sum%2 != 0)
        return false;
    bool part[sum/2+1][n+1];
    for (i = 0; i <= n; i++)
        part[0][i] = true;
    for (i = 1; i <= sum/2; i++)
        part[i][0] = false;
    for (i = 1; i <= sum/2; i++)
    {
        for (j = 1; j <= n; j++)
        {
            part[i][j] = part[i][j-1];
            if (i >= arr[j-1])
                part[i][j] = part[i][j] || part[i - arr[j-1]][j-1];
        }
    }
    return part[sum/2][n];
}

int main() {
    FastIO;
    ll n;
    cin >> n;
    ll s[n+5];
    ll sum=0;
    for (int i=0;i<n;i++){
        cin >> s[i];
        sum+=s[i];
    }
    if(sum%2!=0)cout << "NO";
    else{
        if(findPartiion(s,n))cout << "YES";
        else cout << "NO";
    }

}


#include <bits/stdc++.h>
#define N 100009
#define pii pair <int, int>
#define ff first
#define ss second
#define pb push_back
#define ll long long

using namespace std;

int n, m, v[N];
map<ll, int>c;
ll sum;

int main(){
	cin>>n;
	for(int i=1; i<=n; i++)
		cin>>v[i], sum+=v[i];
	sort(v+1, v+1+n);
	if(sum-v[n]>=v[n] and sum%2==0)
		cout<<"YES";
	else
		cout<<"NO";

/*	int x=n, y=n-1;
	while(1){
		int asd=min(v[x], v[y]);
		v[x]-=asd, v[y]-=asd;
//		cout<<x<<' '<<y<<' '<<v[x]<<' '<<v[y]<<endl;
		if(v[y]==0){
			y--;
			if(x==y)
				y--;
		}
		if(v[x]==0){
			x=y-1;
			if(v[x]==0){
				while(1){
					x--;
					if(v[x]>0 or x<1) break;
				}
			}
		}
		if(x<1 or y<1)
			break;
	}
	if(v[x]<1 and v[y]<1)
		cout<<"YES";
	else
		cout<<"NO";
*/}


#include <bits/stdc++.h>
#define N 100009
#define pii pair <int, int>
#define ff first
#define ss second
#define pb push_back
#define ll long long

using namespace std;

int n, m, v[N];
long long sum;

int main(){
	cin>>n;
	for(int i=2; i<=n; i++)
		cin>>v[i], sum+=v[i];
	if(sum%2==0)
		cout<<"YES";
	else
		cout<<"NO";
}


#include <bits/stdc++.h>
#define N 100009
#define pii pair <int, int>
#define ff first
#define ss second
#define pb push_back
#define ll long long

using namespace std;

int n, m, v[N];
long long sum;

int main(){
	cin>>n;
	for(int i=1; i<=n; i++)
		cin>>v[i], sum+=v[i];
	if(sum % 2==0)
		cout<<"YES";
	else
		cout<<"NO";
}


#include <bits/stdc++.h>
#define N 100009
#define pii pair <int, int>
#define ff first
#define ss second
#define pb push_back
#define ll long long

using namespace std;

int n, m, v[N];
map<ll, int>c;

int main(){
	cin>>n;
	for(int i=1; i<=n; i++)
		cin>>v[i];
	sort(v+1, v+1+n);
	int x=n, y=n-1;
	while(1){
		int asd=min(v[x], v[y]);
		v[x]-=asd, v[y]-=asd;
//		cout<<x<<' '<<y<<' '<<v[x]<<' '<<v[y]<<endl;
		if(v[y]==0){
			y--;
			if(x==y)
				y--;
		}
		if(v[x]==0){
			x=y-1;
			if(v[x]==0){
				while(1){
					x--;
					if(v[x]>0 or x<1) break;
				}
			}
		}
		if(x<1 or y<1)
			break;
	}
	if(v[x]<1 and v[y]<1)
		cout<<"YES";
	else
		cout<<"NO";
}


#include <bits/stdc++.h>
#define N 100009
#define pii pair <int, int>
#define ff first
#define ss second
#define pb push_back
#define ll long long

using namespace std;

int n, m, v[N];
map<ll, int>c;
ll sum;

int main(){
	cin>>n;
	for(int i=1; i<=n; i++)
		cin>>v[i], sum+=v[i];
	sort(v+1, v+1+n);
	if(sum-v[n]>v[n] and sum%2==0)
		cout<<"YES";
	else
		cout<<"NO";

/*	int x=n, y=n-1;
	while(1){
		int asd=min(v[x], v[y]);
		v[x]-=asd, v[y]-=asd;
//		cout<<x<<' '<<y<<' '<<v[x]<<' '<<v[y]<<endl;
		if(v[y]==0){
			y--;
			if(x==y)
				y--;
		}
		if(v[x]==0){
			x=y-1;
			if(v[x]==0){
				while(1){
					x--;
					if(v[x]>0 or x<1) break;
				}
			}
		}
		if(x<1 or y<1)
			break;
	}
	if(v[x]<1 and v[y]<1)
		cout<<"YES";
	else
		cout<<"NO";
*/}


#include <bits/stdc++.h>
#define N 100009
#define pii pair <int, int>
#define ff first
#define ss second
#define pb push_back
#define ll long long

using namespace std;

int n, m, v[N];
long long sum, x;
map<ll, int>c;

int main(){
	cin>>n;
	for(int i=1; i<=n; i++){
		cin>>v[i], sum+=v[i];
		c[v[i]]++;
		if(c[v[i]]%2==1)
			x++;
		else
			x--;
	}
	if(x < 1)
		cout<<"YES";
	else
		cout<<"NO";
}


#include <bits/stdc++.h>
#define N 100009
#define pii pair <int, int>
#define ff first
#define ss second
#define pb push_back
#define ll long long

using namespace std;

int n, m, v[N];
long long sum, x;
map<ll, int>c;

int main(){
	cin>>n;
	for(int i=1; i<=n; i++){
		cin>>v[i], sum+=v[i];
		if(v[i]%2!=0){
			c[v[i]]++;
			if(c[v[i]]%2==1)
				x++;
			else
				x--;
		}
	}
	if(x < 1)
		cout<<"YES";
	else
		cout<<"NO";
}


#include<bits/stdc++.h>

#define fr first
#define se second

using namespace std;

const long long N = 1000 + 7;
const long long INF = 1e18;
const long long mod = 1e9 + 7;

int n;
map< int, int > mp;
int main()
{
    /// freopen("input.txt", "r", stdin);
    /// freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio( 0 );

    cin >> n;
    for ( int i = 1; i <= n; i ++ ){
        int x;
        cin >> x;
        mp[x] ++;
    }
    for ( auto x: mp ){
        if ( x.se % 2 != 0 ){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}


#include<bits/stdc++.h>

#define fr first
#define se second

using namespace std;

const long long N = 1000 + 7;
const long long INF = 1e18;
const long long mod = 1e9 + 7;

int n;
int mx;
int sum;
int main()
{
    /// freopen("input.txt", "r", stdin);
    /// freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio( 0 );

    cin >> n;
    for ( int i = 1; i <= n; i ++ ){
        int x;
        cin >> x;
        sum += x;
        mx = max( mx, x );
    }
    if ( sum / 2 <= mx && sum % 2 == 0 ){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
}


#include <bits/stdc++.h>

#define fr first
#define se second

using namespace std;

const long long N = 1e5 + 7;
const long long inf = 1e18 + 7;
const long long mod = 1e9 + 7;

int n;
int a[N];
int main()
{
    /// freopen( "input.txt", "r", stdin );
    /// freopen( "output.txt", "w", stdout );

    ios_base::sync_with_stdio( false );

    cin >> n;
    for ( int i = 1; i <= n; i ++ ){
        cin >> a[i];
    }
    sort( a + 1, a + n + 1 );
    int l = 1, r = n;
    while( l < r ){
        if ( a[r] > a[l] ){
            a[r] -= a[l];
            a[l++] = 0;
        }
        else if ( a[r] < a[l] ){
            a[l] -= a[r];
            a[r --] = 0;
        }
        else{
            a[l ++] = a[r --] = 0;
        }
    }
    for ( int i = 1; i <= n; i ++ ){
        if ( a[i] % 2 ){
            cout << "NO\n";
            return 0;
        }
    }cout << "YES\n";
}


#include <bits/stdc++.h>

#define fr first
#define se second

using namespace std;

const long long N = 1e5 + 7;
const long long inf = 1e18 + 7;
const long long mod = 1e9 + 7;

int n;
int a[N];
vector< int > b;
map< int, int > used;
int main()
{
    /// freopen( "input.txt", "r", stdin );
    /// freopen( "output.txt", "w", stdout );

    ios_base::sync_with_stdio( false );

    cin >> n;
    for ( int i = 1; i <= n; i ++ ){
        cin >> a[i];
        used[a[i]] ++;
    }
    for ( int i = 1; i <= n; i ++ ){
        if ( used[a[i]] % 2 ){
            b.push_back( a[i] );
            used[a[i]] = 0;
        }
    }
    sort( b.begin(), b.end() );
    int l = 0, r = (int)b.size() - 1;
    while( l < r ){
        if ( b[r] > b[l] ){
            b[r] -= b[l];
            b[l++] = 0;
        }
        else if ( b[r] < b[l] ){
            b[l] -= b[r];
            b[r --] = 0;
        }
        else{
            b[l ++] = b[r --] = 0;
        }
    }
    for ( auto x: b ){
        if ( x % 2 ){
            cout << "NO\n";
            return 0;
        }
    }cout << "YES\n";
}


#include<bits/stdc++.h>

#define fr first
#define se second

using namespace std;

const long long N = 1000 + 7;
const long long INF = 1e18;
const long long mod = 1e9 + 7;

int n;
int mx;
int sum;
int main()
{
    /// freopen("input.txt", "r", stdin);
    /// freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio( 0 );

    cin >> n;
    for ( int i = 1; i <= n; i ++ ){
        int x;
        cin >> x;
        sum += x;
        mx = max( mx, x );
    }
    if ( sum / 2 >= mx && sum % 2 == 0 ){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
}


#include<bits/stdc++.h>

#define fr first
#define se second

using namespace std;

const long long N = 1000 + 7;
const long long INF = 1e18;
const long long mod = 1e9 + 7;

int n;
int mx;
int sum;
int main()
{
    /// freopen("input.txt", "r", stdin);
    /// freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio( 0 );

    cin >> n;
    for ( int i = 1; i <= n; i ++ ){
        int x;
        cin >> x;
        sum += x;
        mx = max( mx, x );
    }
    if ( (sum - mx) / 2 <= mx && sum % 2 == 0 ){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
}


#include<bits/stdc++.h>

#define fr first
#define se second

using namespace std;

const long long N = 1000 + 7;
const long long INF = 1e18;
const long long mod = 1e9 + 7;

int n;
map< int, int > mp;
int main()
{
    /// freopen("input.txt", "r", stdin);
    /// freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio( 0 );

    cin >> n;
    for ( int i = 1; i <= n; i ++ ){
        int x;
        cin >> x;
        mp[x] ++;
    }
    for ( auto x: mp ){
        if ( x.se % 2 == 0 | x.fr % 2 == 0 ){
            continue;
        }
        cout << "NO";
        return 0;
    }
    cout << "YES";
}


#include <bits/stdc++.h>

#define fr first
#define se second

using namespace std;

const long long N = 1e5 + 7;
const long long inf = 1e18 + 7;
const long long mod = 1e9 + 7;

int n;
int mx;
long long sum;
int main()
{
    /// freopen( "input.txt", "r", stdin );
    /// freopen( "output.txt", "w", stdout );

    ios_base::sync_with_stdio( false );

    cin >> n;
    for ( int i = 1; i <= n; i ++ ){
        int x;
        cin >> x;
        sum += x;
        mx = max( mx, x );
    }
    if ( sum % 2 == 0 && ((sum - mx) >= mx) ){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
}


#include <bits/stdc++.h>

#define fr first
#define se second

using namespace std;

const long long N = 1e5 + 7;
const long long inf = 1e18 + 7;
const long long mod = 1e9 + 7;

int n;
int a[N];
vector< int > b;
map< int, int > used;
int main()
{
    /// freopen( "input.txt", "r", stdin );
    /// freopen( "output.txt", "w", stdout );

    ios_base::sync_with_stdio( false );

    cin >> n;
    for ( int i = 1; i <= n; i ++ ){
        cin >> a[i];
        used[a[i]] ++;
    }
    for ( int i = 1; i <= n; i ++ ){
        if ( used[a[i]] % 2 ){
            b.push_back( a[i] );
            used[a[i]] = 0;
        }
    }
    sort( b.begin(), b.end() );
    int l = 0, r = (int)b.size() - 1;
    while( l < r ){
        if ( b[r] > b[l] ){
            b[r] -= b[l];
            b[l++] = 0;
        }
        else if ( b[r] < b[l] ){
            b[l] -= b[r];
            b[r --] = 0;
        }
        else{
            b[l ++] = b[r --] = 0;
        }
    }
    for ( auto x: b ){
        if ( x > 0 ){
            cout << "NO\n";
            return 0;
        }
    }cout << "YES\n";
}


// luogu-judger-enable-o2
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int a[1000005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	if(n==1)
	{
		printf("NO\n");
		return 0;
	}
	sort(a+1,a+1+n);
	int now=n;
	while(now>=2)
	{
		a[now-1]=abs(a[now]-a[now-1]);
		now--;
		if(a[now]==0)
		now--;
	    sort(a+1,a+1+now);
	}
	if(now==0)
	printf("YES\n");
	else
	printf("NO\n");
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	long long a;
	bool kkk=true;
	long long sum=0,maxn=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		if(a%2==1)
		kkk=!kkk;
		if(sum+a<10000000000)
		sum+=a;
		maxn=max(maxn,a);
	}
	if(kkk&&sum-maxn<maxn)
	kkk=false;
	if(n==1)
	kkk=false;
	if(kkk)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, a[100010], maxn;
long long sum;
int main()
{
	cin>>n;
	for(int i=1; i<=n; i++) cin>>a[i], sum+=a[i], maxn=max(maxn, a[i]);
	if(sum%2==0 && maxn<=sum>>1)
	{
		cout<<"YES";
	}else{
		cout<<"NO";
	}
	return 0;
}


#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define eps 1e-7
typedef long long ll;
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;

int n;
ll a[maxn];
int main (){
    while (cin>>n){
        ll s=0;
        int flag=0;
        for (int i=0;i<n;i++) cin>>a[i],s+=a[i];
        sort(a,a+n);
        if (s&1) flag=0;
        else {
            if(a[n-1]>s/2) flag=0;
            else flag=1;
        }
        if(flag) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,maxn,sum;

int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
    {
        ll x;scanf("%lld",&x);
        sum+=x;maxn=max(maxn,x);
    }
    if(sum&1||maxn>sum/2)
        puts("NO");
    else
        puts("YES");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#define il inline
#define res register int
using namespace std;
int n,mx;
long long sum;
int main()
{
	scanf("%d",&n);
	for(res i=1;i<=n;i++)
	{
		int x; scanf("%d",&x);
		sum+=x;
		mx=max(mx,x);
	}
	if(sum&1) cout<<"NO";
	else cout<<"YES";
	return 0;

}


#include <iostream>
using  namespace std;
long long n,a[100001],jsq=0,max_=-1;
int main()
{
	for(long long i=1;i<=n;i++)
	{
		cin>>a[i];
		jsq+=a[i];
		max_=max(a[i],max_);
	}
	if(jsq%2==1||max_*2>jsq)
	cout<<"NO"<<endl;
    else
	cout<<"YES"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,maxn,a;
unsigned long long ans;
int main()
{
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		ans+=a;maxn=max(maxn,a);

	}
	if(!(ans%2)&&maxn*2<=ans) puts("YES");
	else puts("NO");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int Read(){
	int ans=0,fl=1;
	char ch=getchar();
	for(;ch<'0' || ch>'9';ch=getchar())
		if(ch=='-')
			fl=-1;
	for(;ch>='0' && ch<='9';ch=getchar())
		ans=(ans<<3)+(ans<<1)+(ch-'0');
	return ans*fl;
}
const int maxn=1e5+5;
int n,ans,Max,s,a[maxn];
signed main(){
	n=Read();
	for(int i=1;i<=n;i++){
		s+=(a[i]=Read());
		Max=max(Max,a[i]);
	}
	printf("%s\n",((Max<<1)>s)?"NO":((s&1)?"NO":"YES"));
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MAXN = 5e5 + 100;
const int MAXM = 3e3 + 10;

template < typename T > inline void read(T &x) {
	x = 0; T ff = 1, ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') ff = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	x *= ff;
}

template < typename T > inline void write(T x) {
	if(x < 0) putchar('-'), x = -x;
	if(x > 9) write(x / 10);
	putchar(x % 10 + '0');
}

ll n, x, ans, maxx;

int main() {
	read(n);
	for(int i = 1; i <= n; ++i) {
		read(x);
		maxx = max(x, maxx);
		ans += x;
	}
	if((maxx << 1) <= ans && ans % 2 == 0) puts("YES");
	else puts("NO");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;

void read(int &x)
{
	int f=1;
	x=0;
	char s=getchar();
	while (s<'0'||s>'9'){if (s=='-') f=-1;s=getchar();}
	while (s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
	x*=f;
}

int main()
{
	int n,a[100010];
	long long cnt=0;
	read(n);
	for (int i=1;i<=n;i++)
	{
		read(a[i]);
		cnt+=a[i];
	}
	sort(a+1,a+n+1);
	if (a[n]>cnt/2) puts("NO");
	else
	{
		if (cnt%2==0) puts("YES");
			else puts("NO");
	}
}


#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define LL long long
#define maxn 100001
using namespace std;
int n,a[maxn],tot,maxx;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        tot+=a[i];
        maxx=max(a[i],maxx);
    }
    if(tot%2==1||maxx*2>tot) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#include<queue>
#define ll long long
#define maxn 100010
#define inf 2147483647
#define mod 998244353
#define eps 1e-8
using namespace std;
inline int read(){
    int x=0,f=1; char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)) {x=x*10+ch-48;ch=getchar();}
    return x*f;
}
int tot,maxx;
signed main(){
    int n=read();
    for(int i=1;i<=n;i++){
    	int x=read();
    	tot+=x;
    	maxx=max(maxx,x);
    }
	if((tot&1)==1||(maxx<<1)>tot) printf("NO");
	else printf("YES");
    return 0;
}


// luogu-judger-enable-o2
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
long long a[1000005];
long long maxn=0;
int main()
{
	long long n;
	scanf("%lld",&n);
	long long tot;
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		maxn=max(maxn,a[i]);
		tot+=a[i];
	}
	if(tot%2==1 || maxn*2>tot)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	else
	cout<<"YES"<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

long long  n;
long long h[200010],sum;

int main(){
	scanf("%lld",&n);
	for(register int i=1;i<=n;i++){
		scanf("%lld",&h[i]);
		sum+=h[i];
	}
    sort(h+1, h+n+1);
    if ((sum%2==1) || (h[n]/2) > sum)puts("NO");
    else puts("YES");
    return 0;
}


// luogu-judger-enable-o2
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int a[1000005];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	if(n==1)
	{
		printf("NO\n");
		return 0;
	}
	sort(a+1,a+1+n);
	int now=n;
	while(now>=2)
	{
		a[now-1]=a[now]-a[now-1];
		now--;
		if(a[now]==0)
		now--;
	}
	if(now==0)
	printf("YES\n");
	else
	printf("NO\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,ans,maxn,a;
int main()
{
	scanf("%d",&n);
	for(register int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		ans+=a;maxn=max(maxn,a);

	}
	if(ans%2==0&&maxn*2<=ans) puts("YES");
	else puts("NO");
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<string>
#define int long long
#define maxn 100010
#define inf 2147483647
#define mod 998244353
#define eps 1e-8
using namespace std;
inline int read(){
    int x=0,f=1; char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)) {x=x*10+ch-48;ch=getchar();}
    return x*f;
}
int tot,maxx;
signed main(){
    int n=read();
    for(int i=1;i<=n;i++){
    	int x=read();
    	tot+=x;
    	maxx=max(maxx,x);
    }
	if((tot&1)==1||(maxx<<1)>tot) printf("NO");
	else printf("YES");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, a, s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin>>n;
    for (ll i=1; i<=n; i++)
    {
        cin>>a;
        s+=a;
        m=max(m, a);
    }
    if (s%2==1 || s<2*m)
    {
        cout<<"NO";
        return 0;
    }
    cout<<"YES";
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int n;
ll sum=0,m1=0;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		int x;
		scanf("%d",&x);
		sum+=x;
		m1=max(m1,(ll)x);
	}
	if(m1<=sum/2&&sum%2==0)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

int n,x;
map<int,int>mp;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;mp[x]++;
    }
    int jug=0,cnt=0;
    for(auto& i:mp){
        if(i.second%2==1){cnt++;}
    }
    if(cnt%2==1)jug=1;
    if(jug==0){cout<<"YES\n";}
    else{cout<<"NO\n";}

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll n,x,tot;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;tot+=x;
    }
    if(tot%2==0){cout<<"YES";}
    else cout<<"NO";

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

int n,x;
map<int,int>mp;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;mp[x]++;
    }
    int jug=0;
    for(auto& i:mp){
        if(i.second%2==1){jug=1;break;}
    }
    if(jug==0){cout<<"YES\n";}
    else{cout<<"NO\n";}

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll n,x,tot;

int main()
{
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>x;tot+=x;
        tot%=2;
    }
    if(tot%2==0){cout<<"YES";}
    else cout<<"NO";

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

int n,x;
map<int,int>mp;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;mp[x]++;
    }
    int jug=0;
    for(auto& i:mp){
        if(i.second<2){jug=1;break;}
    }
    if(jug==0){cout<<"YES\n";}
    else{cout<<"NO\n";}

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll n,x,tot,jug;
ll a[100005];

int main()
{
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>x;tot+=x;
        a[i]=x;
    }
    jug=0;
    if(tot%2==0){
        sort(a+1,a+1+n);
        if(a[n]>tot-a[n])jug=1;
    }
    else jug=1;
    if(jug==0)cout<<"YES";
    else cout<<"NO";

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll n,x,tot,jug;
ll a[100005];

int main()
{
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>x;tot+=x;
        tot%=2;
        a[i]=x;
    }
    jug=0;
    if(tot%2==0){
        sort(a+1,a+1+n);
        ll j=n;
        for(ll i=1;i<=n;i++){
            if(i==j&&a[i]!=0){jug=1;break;}
            if(a[j]-a[i]>=0){a[j]-=a[i];}
            else{
                a[j]=0;a[i]-=a[j];
                j--;i--;
            }
        }
    }
    else jug=1;
    if(jug==0)cout<<"YES";
    else cout<<"NO";

    return 0;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
long long str[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%I64d",&str[i]);
    int f=1;
    for(int i=2;i<=n;i++)
    {
        str[i]-=str[i-1];
        if(str[i]<0)
        {
            f=0;
            break;
        }
    }
    if(str[n]!=0||!f)
        puts("NO");
    else
        puts("YES");
    return 0;
}
//2019-08-07 19:13:27.663


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long s1[100005];
struct node
{
    long long x;
    int ans;
} s2[100005];
int main()
{
    int n,z=0;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%I64d",&s1[i]);
        if(s1[i]==0)
            z++;
    }
    if(n%2==1)
        puts("NO");
    else
    {
        if(z==n)
            puts("YES");
        else
        {
            sort(s1+1,s1+n+1);
            s2[1].x=s1[1];
            s2[1].ans++;
            int k=1;
            int flag=0;
            for(int i=2; i<=n; i++)
            {
                if(s1[i]!=s2[k].x)
                {
                    k++;
                    s2[k].x=s1[i];
                    s2[k].ans++;
                }
                else
                    s2[k].ans++;
            }
            for(int i=1; i<=k; i++)
            {
                if(s2[i].ans%2==1)
                {
                    flag=1;
                    break;
                }
            }
            if(flag)
                puts("NO");
            else
                puts("YES");
        }
    }
    return 0;
}
//2019-08-07 19:19:11.895


#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int z[100005];
int main()
{
    int n;
    while(cin>>n)
    {
        long long sum=0;
        for(int i=1;i<=n;i++)
        {
            cin>>z[i];
            sum+=(long long)z[i];
        }
        if(sum%2==1)
        {
            cout<<"NO"<<endl;
        }
        else
        {
            cout<<"YES"<<endl;
        }
    }
    return 0;
}
//2019-08-07 19:06:18.628


#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int z[1000005];
int km[100005],vis[100005];
long long sum[1000005];
int main()
{
    int n;
    while(cin>>n)
    {
        for(int i=1; i<=n; i++)
        {
            scanf("%d",&z[i]);
        }
        sort(z+1,z+1+n);
        km[1]=z[1];
        vis[1]=1;
        int d=1;
        for(int i=2; i<=n; i++)
        {
            if(z[i]!=z[i-1])
            {
                d++;
                km[d]=z[i];
                vis[d]=1;
            }
            else
            {
                vis[d]++;
            }
        }
        int g=0,num=0;
        for(int i=1; i<=d; i++)
        {
            if(vis[i]%2==1)
            {
                g++;
                z[g]=km[i];
                sum[g]=sum[g-1]+z[g];
            }
            else
            {
                num+=vis[i];
            }
        }
        if(num==n)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            int flag=0;
            for(int i=1; i<g; i++)
            {
                if(sum[i]==(sum[g]-sum[i]))
                {
                    flag=1;
                    break;
                }
            }
            if(flag==1)
            {
                cout<<"YES"<<endl;
            }
            else
            {
                cout<<"NO"<<endl;
            }
        }
    }
    return 0;
}
//2019-08-07 19:57:19.995


#include<stdio.h>
#include<string.h>
#include<queue>
#include<stack>
#include<math.h>
#include<set>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,a[100005];
int main()
{
    scanf("%I64d",&n);
    for(ll i=0;i<n;i++)
    {
        scanf("%I64d",&a[i]);
    }
    sort(a,a+n);
    ll sum=0,sum1;
    for(ll i=0;i<n;i++)
    {
        sum+=a[i];
    }
    sum1=sum-a[n-1];
    if(sum%2==1||a[n-1]>sum1)
    {
        printf("NO\n");
    }
    else
    {
        printf("YES\n");
    }
    return 0;
}
//2019-08-07 20:27:29.74


#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
typedef long long ll;

int main()
{
     ll n,x,maxn=0,sum=0;
     scanf("%I64d",&n);
     for(ll i=1;i<=n;i++)
     {
         scanf("%I64d",&x);
         sum+=x;
         maxn=max(maxn,x);
     }
     if(sum%2==1)
        printf("NO\n");
     else if(sum-maxn>=maxn)
     {
         printf("YES\n");
     }
     else printf("NO\n");
     return 0;
}
//2019-08-07 20:44:06.051


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long s1[100005];
struct node{
long long x;
int ans;
}s2[100005];
int main()
{
    int n,z=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
             scanf("%I64d",&s1[i]);
             if(s1[i]==0)
                z++;
    }
   if(z==n)
    puts("NO");
   else
   {
        sort(s1+1,s1+n+1);
    s2[1].x=s1[1];
    s2[1].ans++;
    int k=1;
    int flag=0;
    for(int i=2;i<=n;i++)
    {
        if(s1[i]!=s2[k].x)
        {
            k++;
            s2[k].x=s1[i];
            s2[k].ans++;
        }
        else
            s2[k].ans++;
    }
    for(int i=1;i<=k;i++)
    {
        if(s2[i].ans%2==1)
        {
            flag=1;
            break;
        }
    }
    if(flag)
        puts("NO");
    else
        puts("YES");
   }
    return 0;
}
//2019-08-07 19:16:25.839


#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <math.h>
#include <iostream>
#include <string.h>
const int MAX=1e5+5;
using namespace std;
typedef long long ll;
int main()
{
  int n, i, j;
  cin >> n;
  ll a[n+5], now=0;
  for (i=0; i<n; i++)
  {
    scanf("%I64d", &a[i]);
    now = abs(a[i]-now);
  }
  if (now) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}
//2019-08-07 20:12:24.883


/*
h3110_fr13nd,

AUTHOR : @sam_jn
*/

#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 998244353
#define pb push_back
#define ff first
#define ss second
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot1(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int find(int i);
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}

//----------------------------------SOLUTION-BELOW-------------------------------------------//

void solve(){
    ll n, x;
    cin >> n;
    ll a[n];
    in(a, n);
    sort(a, a + n);
    ll f = accumulate(a, a + n, 0LL);

    if((f % 2 == 0) && (f - a[n - 1] >= a[n - 1])){
        cout << "YES";
    }
    else cout << "NO";
}
int main(){
                                                            #ifndef ONLINE_JUDGE
                                                            freopen("../input", "r", stdin);
                                                            freopen("../output", "w", stdout);
                                                            #else
                                                            // online submission
                                                            #endif
    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}

//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)
{
    if (baap[i] != i)
        baap[i] = find(baap[i]);

    return baap[i];
}

bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}


/*
h3110_fr13nd,

AUTHOR : @sam_jn
*/

#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 998244353
#define pb push_back
#define ff first
#define ss second
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot1(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int find(int i);
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}

//----------------------------------SOLUTION-BELOW-------------------------------------------//
ll fac(ll x){
	return (x * (x + 1)) / 2;
}
void solve(){
	ll n, x;
	cin >> n;
	ll a[n];
	in(a, n);
	sort(a, a + n);
	ll f = accumulate(a, a + n, 0) / n;
	for(int i = 0; i < n; i++){
		if(a[i] < f) {
			cout << "NO";
			return;
		}
	}
	cout << "YES";
}
int main(){
                                                            #ifndef ONLINE_JUDGE
                                                            freopen("../input", "r", stdin);
                                                            freopen("../output", "w", stdout);
                                                            #else
                                                            // online submission
                                                            #endif
    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}

//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)
{
    if (baap[i] != i)
        baap[i] = find(baap[i]);

    return baap[i];
}

bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}


/*
h3110_fr13nd,

AUTHOR : @sam_jn
*/

#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 998244353
#define pb push_back
#define ff first
#define ss second
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot1(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int find(int i);
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}

//----------------------------------SOLUTION-BELOW-------------------------------------------//

void solve(){
    ll n, x;
    cin >> n;
    ll a[n];
    in(a, n);
    sort(a, a + n);
    ll f = accumulate(a, a + n, 0);

    if((f % 2 == 0) && (f - a[n - 1] >= a[n - 1])){
        cout << "YES";
    }
    else cout << "NO";
}
int main(){
                                                            #ifndef ONLINE_JUDGE
                                                            freopen("../input", "r", stdin);
                                                            freopen("../output", "w", stdout);
                                                            #else
                                                            // online submission
                                                            #endif
    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}

//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)
{
    if (baap[i] != i)
        baap[i] = find(baap[i]);

    return baap[i];
}

bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}


/*
h3110_fr13nd,

AUTHOR : @sam_jn
*/

#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 998244353
#define pb push_back
#define ff first
#define ss second
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot1(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int find(int i);
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}

//----------------------------------SOLUTION-BELOW-------------------------------------------//

void solve(){
    ll n, x;
    cin >> n;
    ll a[n];
    in(a, n);
    ll f = accumulate(a, a + n, 0) / n;
    for(int i = 0; i < n; i++){
        if(a[i] < f) {
            cout << "NO";
            return;
        }
    }
    cout << "YES";
}
int main(){
                                                            #ifndef ONLINE_JUDGE
                                                            freopen("../input", "r", stdin);
                                                            freopen("../output", "w", stdout);
                                                            #else
                                                            // online submission
                                                            #endif
    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}

//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)
{
    if (baap[i] != i)
        baap[i] = find(baap[i]);

    return baap[i];
}

bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}


/*
h3110_fr13nd,

AUTHOR : @sam_jn
*/

#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 998244353
#define pb push_back
#define ff first
#define ss second
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot1(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int find(int i);
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}

//----------------------------------SOLUTION-BELOW-------------------------------------------//

void solve(){
    ll n, x;
    cin >> n;
    ll a[n];
    in(a, n);
    sort(a, a + n);
    ll f = accumulate(a, a + n, 0);
    if(f % 2){
        cout << "NO";
        return;
    }
    if(f - a[n - 1] >= a[n - 1]){
        cout << "YES";
        return;
    }
    cout << "NO";
}
int main(){
                                                            #ifndef ONLINE_JUDGE
                                                            freopen("../input", "r", stdin);
                                                            freopen("../output", "w", stdout);
                                                            #else
                                                            // online submission
                                                            #endif
    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}

//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)
{
    if (baap[i] != i)
        baap[i] = find(baap[i]);

    return baap[i];
}

bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}


/*
h3110_fr13nd,

AUTHOR : @sam_jn
*/

#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 998244353
#define pb push_back
#define ff first
#define ss second
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot1(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int find(int i);
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}

//----------------------------------SOLUTION-BELOW-------------------------------------------//
ll fac(ll x){
	return (x * (x + 1)) / 2;
}
void solve(){
	ll n, x;
	cin >> n;
	priority_queue<ll> pq;
	for(int i = 0; i < n; i++){
		cin >> x;
		pq.push(x);
	}
	while(!pq.empty() && pq.top()){
		// for(auto i : pq) cout << i << " ";
		// cout << endl;
		ll a = pq.top();
		pq.pop();
		if(pq.empty() || (pq.top() == 0)){
			cout << "NO";
			return;
		}
		ll b = pq.top();
		pq.pop();
		pq.push(a - b);
	}
	cout << "YES";
}
int main(){
                                                            #ifndef ONLINE_JUDGE
                                                            freopen("../input", "r", stdin);
                                                            freopen("../output", "w", stdout);
                                                            #else
                                                            // online submission
                                                            #endif
    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}

//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)
{
    if (baap[i] != i)
        baap[i] = find(baap[i]);

    return baap[i];
}

bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}


/*
h3110_fr13nd,

AUTHOR : @sam_jn
*/

#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 998244353
#define pb push_back
#define ff first
#define ss second
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot1(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int find(int i);
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}

//----------------------------------SOLUTION-BELOW-------------------------------------------//

void solve(){
    ll n, x;
    cin >> n;
    ll a[n];
    in(a, n);
    ll f = accumulate(a, a + n, 0);
    if(f % 2){
        cout << "NO";
        return;
    }
    f /= n;
    for(int i = 0; i < n; i++){
        if(a[i] < f) {
            cout << "NO";
            return;
        }
    }
    cout << "YES";
}
int main(){
                                                            #ifndef ONLINE_JUDGE
                                                            freopen("../input", "r", stdin);
                                                            freopen("../output", "w", stdout);
                                                            #else
                                                            // online submission
                                                            #endif
    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}

//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)
{
    if (baap[i] != i)
        baap[i] = find(baap[i]);

    return baap[i];
}

bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

vector <long long> a;
vector <int> usd;

int main()
{
    //ios_base::sync_with_stdio(false);
    long long n, ans = 0, k1 = 0, k2 = 0;
    cin >> n;
    a.resize(n);
    usd.resize(n);
    for (int i = 0; i < n; i ++){
        cin >> a[i];
        ans += a[i];
        usd[i] = 0;
    }
    if (ans % 2 == 1){
        cout << "NO";
        return 0;
    }
    if (ans % n == 1){
        cout << "NO";
        return 0;
    }
    cout << "YES";
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

vector <long long> a;
vector <int> usd;

int main()
{
    //ios_base::sync_with_stdio(false);
    long long n, ans = 0, k1 = 0, k2 = 0;
    cin >> n;
    a.resize(n);
    usd.resize(n);
    for (int i = 0; i < n; i ++){
        cin >> a[i];
        usd[i] = 0;
    }
    sort(a.begin(), a.end());
    for (int i = 1; i < n; i ++){
        if (a[i] == a[i - 1] && usd[i] == 0 && usd[i - 1] == 0){
            ans += a[i] * 2;
            usd[i] = 1;
            usd[i - 1] = 1;
            k1 = 1;
        }
    }
    for (int i = 0; i < n; i ++){
        if (usd[i] == 0){
            k2 = 0;
            ans -= usd[i];
        }
    }
    //cout << ans << " " << k1 << " " << k2 << "\n";
    if (ans == 0 && k2 || k1 && ans){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

vector <long long> a;

//4 _ 1 1 2 2     YES 6
//4 _ 2 6 3 5     YES 16
//3 _ 2 2 1000    NO  1004
//6 _ 1 2 3 4 5 6 NO  21
//3 _ 2 2 4       YES 8

int main()
{
    //ios_base::sync_with_stdio(false);
    long long n, ans = 0;
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i ++) {
        cin >> a[i];
        ans += a[i];
    }
    sort(a.begin(), a.end());
    if (ans % 2 == 1) {
        cout << "NO";
        return 0;
    }
    //cout << ans << " " << n;
    if (2 * a[n - 1] >= ans) {
        cout << "NO";
        return 0;
    }
    cout << "YES";
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

vector <long long> a;
vector <int> usd;

int main()
{
    //ios_base::sync_with_stdio(false);
    long long n, ans = 0, k1 = 0, k2 = 0;
    cin >> n;
    a.resize(n);
    usd.resize(n);
    for (int i = 0; i < n; i ++){
        cin >> a[i];
        ans += a[i];
        usd[i] = 0;
    }
    if (ans % 2 != 1){
        cout << "NO";
        return 0;
    }
    sort(a.begin(), a.end());
    ans = 0;
    for (int i = 1; i < n; i ++){
        if (a[i] == a[i - 1] && usd[i] == 0 && usd[i - 1] == 0){
            ans += a[i] * 2;
            usd[i] = 1;
            usd[i - 1] = 1;
            k1 = 1;
        }
    }
    for (int i = 0; i < n; i ++){
        if (usd[i] == 0){
            k2 = 0;
            ans -= usd[i];
        }
    }
    //cout << ans << " " << k1 << " " << k2 << "\n";
    if (ans == 0 && k2 || k1 && ans){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

vector <long long> a;

//4 _ 1 1 2 2     YES 6
//4 _ 2 6 3 5     YES 16
//3 _ 2 2 1000    NO  1004
//6 _ 1 2 3 4 5 6 NO  21
//3 _ 2 2 4       YES 8

int main()
{
    //ios_base::sync_with_stdio(false);
    long long n, ans = 0;
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i ++) {
        cin >> a[i];
        ans += a[i];
    }
    sort(a.begin(), a.end());
    if (ans % 2 == 1) {
        cout << "NO";
        return 0;
    }
    //cout << ans << " " << n;
    if (2 * a[n - 1] > ans) {
        cout << "NO";
        return 0;
    }
    cout << "YES";
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

vector <long long> a;
vector <int> usd;

int main()
{
    //ios_base::sync_with_stdio(false);
    long long n, ans = 0, kill = 0;
    cin >> n;
    a.resize(n);
    usd.resize(n);
    for (int i = 0; i < n; i ++){
        cin >> a[i];
        usd[i] = 0;
    }
    sort(a.begin(), a.end());
    for (int i = 1; i < n; i ++){
        if (a[i] == a[i - 1] && usd[i] == 0 && usd[i - 1] == 0){
            ans += a[i] * 2;
            usd[i] = 1;
            usd[i - 1] = 1;
            kill = 1;
        }
    }
    for (int i = 0; i < n; i ++){
        if (usd[i] == 0){
            kill = 0;
            ans -= usd[i];
        }
    }
    if (ans == 0 && kill){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

vector <long long> a;
vector <int> usd;

int main()
{
    //ios_base::sync_with_stdio(false);
    long long n, ans = 0, kill = 1;
    cin >> n;
    a.resize(n);
    usd.resize(n);
    for (int i = 0; i < n; i ++){
        cin >> a[i];
        usd[i] = 0;
    }
    sort(a.begin(), a.end());
    for (int i = 1; i < n; i ++){
        if (a[i] == a[i - 1] && usd[i] == 0 && usd[i - 1] == 0){
            ans += a[i] * 2;
            usd[i] = 1;
            usd[i - 1] = 1;
        }
    }
    for (int i = 0; i < n; i ++){
        if (usd[i] == 0){
            kill = 0;
            ans -= usd[i];
        }
    }
    if (ans == 0 || kill){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;

vector <long long> a;
vector <int> usd;

int main()
{
    //ios_base::sync_with_stdio(false);
    long long n, ans = 0, k1 = 0, k2 = 0;
    cin >> n;
    a.resize(n);
    usd.resize(n);
    for (int i = 0; i < n; i ++){
        cin >> a[i];
        ans += a[i];
        usd[i] = 0;
    }
    if (ans % 2 == 1){
        cout << "NO";
        return 0;
    }
    sort(a.begin(), a.end());
    ans = 0;
    for (int i = 1; i < n; i ++){
        if (a[i] == a[i - 1] && usd[i] == 0 && usd[i - 1] == 0){
            ans += a[i] * 2;
            usd[i] = 1;
            usd[i - 1] = 1;
            k1 = 1;
        }
    }
    for (int i = 0; i < n; i ++){
        if (usd[i] == 0){
            k2 = 0;
            ans -= usd[i];
        }
    }
    //cout << ans << " " << k1 << " " << k2 << "\n";
    if (ans == 0 && k2 || k1 && ans){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <math.h>
#include <map>
#include <vector>
#include <set>

#define MAX_N 300005
#define f first
#define s second

using namespace std;

typedef pair<int, int> ii;
typedef pair<ii, int> pii;

map<int, bool> vis;

int ar[MAX_N];
int N, M;

int main() {
    cin >> N;

    for (int i = 0; i < N; i ++)
        cin >> ar[i];

    sort(ar, ar + N);

    if (ar[N - 1] == ar[N - 2])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return (0);
}


#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <math.h>
#include <map>
#include <vector>
#include <set>

#define MAX_N 300005
#define f first
#define s second

using namespace std;

typedef pair<int, int> ii;
typedef pair<ii, int> pii;

map<int, bool> vis;

int ar[MAX_N];
int N, M;

int main() {
    cin >> N;

    long long sum = 0;
    for (int i = 0; i < N; i ++) {
        cin >> ar[i];
        sum += ar[i];
    }

    sort(ar, ar + N);

    if (ar[N - 1] > (sum / 2) || (sum % 2 == 1)) {
        cout << "NO" << endl;
        return (0);
    } else {
        long long mod = (ar[0] % 2) * (N % 2);

        for (int i = 1; i < N; i ++)
            if (ar[i] != ar[i - 1])
                mod += ((ar[i] - ar[i - 1]) % 2) * ((N - i) % 2);

        cout << (mod % 2 == 0 ? "YES" : "NO") << endl;
    }

    return (0);
}


#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <math.h>
#include <map>
#include <vector>
#include <set>

#define MAX_N 300005
#define f first
#define s second

using namespace std;

typedef pair<int, int> ii;
typedef pair<ii, int> pii;

map<int, bool> vis;

int ar[MAX_N];
int N, M;

int main() {
    cin >> N;

    for (int i = 0; i < N; i ++)
        cin >> ar[i];

    sort(ar, ar + N);

    int mod = (ar[0] % 2) * (N % 2);
    for (int i = 1; i < N; i ++)
        if (ar[i] != ar[i - 1])
            mod += ((ar[i] - ar[i - 1]) % 2) * ((N - i) % 2);

    cout << (mod % 2 == 0 ? "YES" : "NO") << endl;
    return (0);
}


#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <math.h>
#include <map>
#include <vector>
#include <set>

#define MAX_N 300005
#define f first
#define s second

using namespace std;

typedef pair<int, int> ii;
typedef pair<ii, int> pii;

map<int, bool> vis;

int ar[MAX_N];
int N, M;

int main() {
    cin >> N;

    for (int i = 0; i < N; i ++)
        cin >> ar[i];

    sort(ar, ar + N);

    if (N % 2 == 0) {
        if (ar[N - 1] == ar[N - 2]) { cout << "YES" << endl; }
        else { cout << "NO" << endl; }
    } else {
        int mod = (ar[0] % 2) * (N % 2);

        for (int i = 1; i < N; i ++)
            if (ar[i] != ar[i - 1])
                mod += ((ar[i] - ar[i - 1]) % 2) * ((N - i) % 2);

        cout << (mod % 2 == 0 ? "YES" : "NO") << endl;
    }

    return (0);
}


#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <math.h>
#include <map>
#include <vector>
#include <set>

#define MAX_N 300005
#define f first
#define s second

using namespace std;

typedef pair<int, int> ii;
typedef pair<ii, int> pii;

int ar[MAX_N];
int N, M;

int main() {
    cin >> N;

    multiset<int> q;

    for (int i = 0; i < N; i ++) {
        cin >> ar[i];
        q.insert(ar[i]);
    }

    while (q.size() > 1) {
        int small = *q.begin();
        int big = *q.rbegin();

        multiset<int>::iterator ms_iterator;

        ms_iterator = q.begin();
        q.erase(ms_iterator);

        q.erase(std::prev(q.end()));

        if (big - small > 0)
            q.insert(big - small);
    }

    if (q.size() == 0)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return (0);
}


#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <math.h>
#include <map>
#include <vector>
#include <set>

#define MAX_N 300005
#define f first
#define s second

using namespace std;

typedef pair<int, int> ii;
typedef pair<ii, int> pii;

map<int, bool> vis;

int ar[MAX_N];
int N, M;

int main() {
    cin >> N;

    int sum = 0;
    for (int i = 0; i < N; i ++) {
        cin >> ar[i];
        sum += ar[i];
    }

    sort(ar, ar + N);

    //if (ar[N - 1] > (sum / 2) || (sum % 2 == 1)) {
    //    cout << "NO" << endl;
    //    return (0);
    //} else {
        int mod = (ar[0] % 2) * (N % 2);

        for (int i = 1; i < N; i ++)
            if (ar[i] != ar[i - 1])
                mod += ((ar[i] - ar[i - 1]) % 2) * ((N - i) % 2);

        cout << (mod % 2 == 0 ? "YES" : "NO") << endl;
    //}

    return (0);
}


#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <math.h>
#include <map>
#include <vector>
#include <set>

#define MAX_N 300005
#define f first
#define s second

using namespace std;

typedef pair<int, int> ii;
typedef pair<ii, int> pii;

map<int, bool> vis;

int ar[MAX_N];
int N, M;

int main() {
    cin >> N;

    int sum = 0;
    for (int i = 0; i < N; i ++) {
        cin >> ar[i];
        sum += ar[i];
    }

    sort(ar, ar + N);

    if (ar[N - 1] > (sum / 2) || (sum % 2 == 1)) {
        cout << "NO" << endl;
        return (0);
    } else {
        int mod = (ar[0] % 2) * (N % 2);

        for (int i = 1; i < N; i ++)
            if (ar[i] != ar[i - 1])
                mod += ((ar[i] - ar[i - 1]) % 2) * ((N - i) % 2);

        cout << (mod % 2 == 0 ? "YES" : "NO") << endl;
    }

    return (0);
}


#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <math.h>
#include <map>
#include <vector>
#include <set>

#define MAX_N 300005
#define f first
#define s second

using namespace std;

typedef pair<int, int> ii;
typedef pair<ii, int> pii;

map<int, bool> vis;

int ar[MAX_N];
int N, M;

int main() {
    cin >> N;

    for (int i = 0; i < N; i ++)
        cin >> ar[i];

    sort(ar, ar + N);

    int mod = (ar[0] % 2) * (N % 2);
    for (int i = 1; i < N; i ++)
        if (ar[i] != ar[i - 1])
            mod += ((ar[i] - ar[i - 1]) % 2) * ((N - i) % 2);

    if (ar[N - 1] > ar[N - 2] + 1) {
        cout << "NO" << endl;
        return (0);
    }

    cout << (mod % 2 == 0 ? "YES" : "NO") << endl;
    return (0);
}


#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <math.h>
#include <map>
#include <vector>
#include <set>

#define MAX_N 300005
#define f first
#define s second

using namespace std;

typedef pair<int, int> ii;
typedef pair<ii, int> pii;

int ar[MAX_N];
int N, M;

int main() {
    cin >> N;

    int sum = 0;
    int big = 0;

    for (int i = 0; i < N; i ++) {
        cin >> ar[i];
        sum += ar[i];

        big = max(big, ar[i]);
    }

    if (sum % 2 == 1) {
        cout << "NO" << endl;
        return (0);
    }

    if (big <= sum / 2)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return (0);
}


#include <iostream>
#include <algorithm>
#include <queue>
#include <string.h>
#include <math.h>
#include <map>
#include <vector>
#include <set>

#define MAX_N 300005
#define f first
#define s second

using namespace std;

typedef pair<int, int> ii;
typedef pair<ii, int> pii;

map<int, bool> vis;

int ar[MAX_N];
int N, M;

int main() {
    cin >> N;

    for (int i = 0; i < N; i ++)
        cin >> ar[i];

    sort(ar, ar + N);

    int mod = (ar[0] % 2) * (N % 2);
    for (int i = 1; i < N; i ++)
        if (ar[i] != ar[i - 1])
            mod += ((ar[i] - ar[i - 1]) % 2) * ((N - i) % 2);

    if (ar[N - 1] != ar[N - 2] && N == 2) {
        cout << "NO" << endl;
        return (0);
    }

    cout << (mod % 2 == 0 ? "YES" : "NO") << endl;
    return (0);
}


#include<bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)

#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
        freopen("debug.txt","w",stderr);
	#endif
	fast;
	ll n,q,l,r,x,i;
	cin >> n >> q;
	ll arr[n];
	map<int,vector<int> > mp;
	//vector<int> vt[1000000];
	for(i=0;i<n;i++)
	{
		cin >> arr[i];
		mp[arr[i]].push_back(i+1);
	}
	while(q--)
	{
		cin >> l >> r >> x;
		//dbg(l);
		//dbg(mp[x]);
		if(mp[x].size()==0)
		{
			cout << l << endl;
			continue;
		}
		int flag=0;
		for(i=0;i<mp[x].size();i++)
		{
		// //	dbg(mp[x][i]);
		// 	if(mp[x][i]<l || mp[x][i]>r)
		// 		continue;
		// 	if(mp[x][i]==l)
		// 	{
		// 		l++;
		// 		flag=1;
		// 	}
		// 	else
		// 		break;
			if(mp[x][i]>=l & mp[x][i]<=r)
			{
				if(mp[x][i]==l)
					l++;
			}
		//	dbg(l);
		}
		//dbg(l);
		//dbg(flag)
		if(l>r)
			cout << -1 << endl;
		else
			cout << l << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)

#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
        freopen("debug.txt","w",stderr);
	#endif
	fast;
	ll n,q,l,r,x,i;
	cin >> n >> q;
	ll arr[n];
	map<int,vector<int> > mp;
	//vector<int> vt[1000000];
	for(i=0;i<n;i++)
	{
		cin >> arr[i];
		mp[arr[i]].push_back(i+1);
	}
	while(q--)
	{
		cin >> l >> r >> x;
		//dbg(l);
		//dbg(mp[x]);
		if(mp[x].size()==0)
		{
			cout << l << endl;
			continue;
		}
		for(i=0;i<mp[x].size();i++)
		{
			dbg(mp[x][i]);
			if(mp[x][i]<l || mp[x][i]>r)
				continue;
			if(mp[x][i]==l)
				l++;
			else
				break;
			//dbg(l);
		}
		//dbg(l);
		if(l>=r)
			cout << -1 << endl;
		else
			cout << l << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)

#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
        freopen("debug.txt","w",stderr);
	#endif
	fast;
	ll n,m,i,l,r,x;
	cin >> n >> m;
	ll arr[n],pre[n];
	for(i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	pre[0]=-1;
	for(i=1;i<n;i++)
	{
		if(arr[i]==arr[i-1])
			pre[i]=pre[i-1];
		else
			pre[i]=i-1;
	}
	for(i=0;i<n;i++)
	{
	//	cout<< pre[i] <<" ";
	}
	while(m--)
	{
		cin >> l >> r >> x;
		l--;
		r--;
		if(arr[r]!=x)
			cout << r+1 << endl;
		else if(pre[r]>l)
			cout << pre[r]+1 << endl;
		else
			cout << -1 << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<ll> vi;

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define nl cout<<'\n'
#define pb push_back
#define all(s) s.begin(),s.end()
#define bs binary_search

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a)*(b)/(__gcd((a),(b)))

const int Mod=1e9+7;
#define sum(a,b) (((a)%Mod)+((b)%Mod))%Mod
#define sub(a,b) (((a)%Mod)-((b)%Mod))%Mod
#define mul(a,b) (((a)%Mod)*((b)%Mod))%Mod
#define digit(x) floor((log10(x))+1)

#define count1(x) __builtin_popcount(x)

#define dbg(x) cout << #x <<":"<<x<<endl;

bool isPowerOfTwo (int x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}

ll pow(ll x, ll y, ll mod)
{
	int ans=1;
	while(y)
	{
		if(y&1)
			ans=(ans*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}
	return ans;
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
        freopen("debug.txt","w",stderr);
	#endif
	fast;
	ll n,m,i,l,r,x;
	cin >> n >> m;
	ll arr[n],pre[n];
	for(i=0;i<n;i++)
	{
		cin >> arr[i];
	}
	pre[0]=-1;
	for(i=1;i<n;i++)
	{
		if(arr[i]==arr[i-1])
			pre[i]=pre[i-1];
		else
			pre[i]=i-1;
	}
	for(i=0;i<n;i++)
	{
	//	cout<< pre[i] <<" ";
	}
	while(m--)
	{
		cin >> l >> r >> x;
		l--;
		r--;
		if(arr[r]!=x)
			cout << r+1 << endl;
		else if(pre[r]>=l)
			cout << pre[r]+1 << endl;
		else
			cout << -1 << endl;
	}
}