#include #include #include #include #include #include #include using namespace std; static const int MAX_N = 1000005; int main() { int n, a, b, t[101] = {}; vectorv, w; cin >> n; for (int i = 0; i < n; i++) { cin >> a; v.push_back(a); } int sum = 0; for (int i = 0; i < n; i++) { cin >> b; if (b == 0)sum += v[i]; else t[b] += v[i]; } sort(t, t + 101); if (sum >= t[100])cout << "YES" << endl; else cout << "NO" << endl; return 0; }