#include #include #include #include using namespace std; int main(){ int n; cin>> n; vector a(n), b(n); map mp; for(int i=0; i> a[i]; } for(int i=0; i> b[i]; mp[b[i]] += a[i]; } int k = mp[0]; mp[0] = 0; int mx=-1; auto itr = mp.begin(); for(; itr!=mp.end(); itr++){ mx = max(mx, itr->second); } if(k>=mx){ cout<< "YES"<< endl; }else{ cout<< "NO"<< endl; } return 0; }