#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     sort(a.begin(), a.end());     bool ok = true;     int cur = -1;     int q = 0;     for (int i = 0; i < n; ++i) {       if (q == 0) {         if (cur != -1 && a[i] != a[i - 1]) {           ok = false;           break;         }         q = 1;         cur = a[i];       } else {         if (cur == a[i]) {           ++q;         } else {           if (cur == a[i] - 1) {             --q;           } else {             ok = false;             break;           }         }       }     }     ok &= q == 0;     if (ok) {       cout <<  YES n ;     } else {       cout <<  NO n ;     }     return 0;   }   