#include #define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++) const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, 1, 0, -1}; using namespace std; typedef long long ll; typedef vector vi; typedef vector vll; typedef pair pii; int a[111], b[111]; int point[111]; bool ok() { for (int i = 1; i < 111; i++) { if (point[0] < point[i]) return false; } return true; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; int p = 0, q = 0; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; point[b[i]] += a[i]; } if (ok()) cout << "YES" << endl; else cout << "NO" << endl; return 0; }