#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <typeinfo>
#include <climits>
#include <ctype.h>
#include <string>
#include <stdio.h>
using namespace std;
#define INIT cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)

int main()
{
    INIT;

    int n;
    cin >> n;
    int A[n], B[n];
    REP(i, n) cin >> A[i];
    int ma = INT_MIN;
    REP(i, n){
        cin >> B[i];
        ma = max(ma, B[i]);
    }
    int T[ma + 1] = {};

    int k = 0;
    REP(i, n){
        if(B[i] == 0) k += A[i];
        else T[B[i]] += A[i];
    }
    
    int f = 0;
    REP(i, ma + 1){
        if(k < T[i]){
            cout << "NO" << endl;
            f = 1;
            break;
        }
    }
    if(f == 0) cout << "YES" << endl; 

    return 0;
}