#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]-1] += data1[i]; } for(int i = 0; i < n; i++){ if(count < score[i]){ cout << "NO" << endl; return 0; } } cout << "YES" << endl; return 0; }