#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; int s = 0; vector a(N),b(N),c(101,0); rep(i,N) cin >> a[i]; rep(i,N){ int b; cin >> b; c[b] += a[i]; } int ma = 0; rep(i,101) ma = max(ma, c[i]); cout << (ma == c[0] ? "YES" : "NO") << endl; }