#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef pair pii; typedef pair pll; typedef vector vi; #define rep(i,x) for(int i=0;i<(int)(x);++i) #define reps(i,x) for(int i=1;i<=(int)(x);++i) #define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--) #define rreps(i,x) for(int i=((int)(x));i>0;i--) #define pb push_back int n, player; int map_max(map M){ int mx = 0; map::iterator itr; for (itr = M.begin(); itr != M.end(); itr++) { if (mx < itr->second) mx = itr->second; } return mx; } int main(){ cin.tie(0); ios::sync_with_stdio(false); map ps; cin >> n; vi score(n); rep(i, n) cin >> score[i]; rep(i, n) { cin >> player; ps[player] += score[i]; } int top = map_max(ps); cout << (top <= ps[0] ? "YES" : "NO") << "\n"; return 0; }