#include using namespace std; int main(){ int n; cin >> n; map mp; for(int i=0; i> s; if(mp[s] == 0) mp[s] = 1; else mp[s]++; } int cnt = 0; for(auto itr=mp.begin(); itr!=mp.end(); itr++){ auto p = (*itr); if(p.second != 1){ cnt = p.second-1; itr++; for(auto jtr=itr; jtr!=mp.end(); jtr++){ auto q = (*jtr); if(cnt - q.second > 0) cnt -= q.second; else{ q.second -= cnt; cnt = 0; } } } if(cnt != 0){ cout << "NO" << endl; return 0; } } cout << "YES" << endl; }