#include <bits/stdc++.h>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	vector<int> a(n), b(101);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		b[x] += a[i];
	}
	int m = 0;
	for(int i = 0; i < 101; i++) {
		m = max(m, b[i]);
	}
	if(m == b[0]) puts("YES");
	else puts("NO");
	return 0;	
}