#include #include using namespace std; int main(){ int n; cin >> n; vector data1(n); vector data2(n); vector score(n,0); for(auto &a:data1) cin >> a; for(auto &b:data2) cin >> b; int count = 0; for(int i = 0; i < n; i++){ if(data2[i] == 0) count += data1[i]; else score[data2[i]] += data1[i]; } for(int i = 0; i < n; i++){ if(count < score[i]){ cout << "NO" << endl; exit(1); } } cout << "YES" << endl; return 0; }