#include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(i,s,e) for (int i = int(s); i != int(e); i++) #define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) #define ISEQ(c) (c).begin(), (c).end() int main(){ int N; cin >> N; int a[N]; int b[N]; FOR (i,0,N) cin >> a[i]; FOR (i,0,N) cin >> b[i]; int getP = 0; int others[104] = {0}; FOR (i,0,N){ if (b[i] == 0) getP += a[i]; else others[b[i]] += a[i]; } int max = 0; FOR (i,0,101){ if (max <= others[i]) max = others[i]; } string ans = ""; if (max <= getP) ans = "YES"; else ans = "NO"; cout << ans << endl; return 0; }