#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int N, A[105], B[105], score[105] = {}; cin >> N; for (int i = 0; i < N; i++) cin >> A[i]; for (int i = 0; i < N; i++) cin >> B[i]; for (int i = 0; i < N; i++) { score[B[i]] += A[i]; } int s = score[0]; score[0] = 0; sort(score, score+105); if (score[104] > s) cout << "NO" << endl; else cout << "YES" << endl; return 0; }