#include using namespace std; int main() { int n; cin >> n; vector a(n); for (int &e : a) cin >> e; vector p(101, 0); for (int i = 0; i < n; i++) { int j; cin >> j; p[j] += a[i]; } if (p[0] == *max_element(p.begin(), p.end())) { cout << "YES" << '\n'; } else { cout << "NO" << '\n'; } return 0; }