#include <bits/stdc++.h>
using namespace std;
long long a[114514];
int main() {
  long long n;
  cin >> n;
  map<long long, long long> mp;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  if (mp[0] == n)
    cout << "YES";
  else if (n % 3)
    cout << "NO";
  else {
    sort(a, a + n);
    if ((mp[0] == n / 3 && mp[a[n / 3]] == 2 * n / 3) ||
        (mp[a[0]] == n / 3 && mp[a[n / 3]] == n / 3 &&
         mp[a[2 * n / 3]] == n / 3))
      cout << "YES";
    else
      cout << "NO";
  }
  return 0;
}
