#include #include using namespace std; int main(){ int k,n; cin >> n; int a[n],b[n],all[101] = {}; 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++) all[b[i]] += a[i]; k = all[0]; stable_sort(all,all + 101); cout << (k == all[100] ? "YES" : "NO") << endl; }