#include #include #include using namespace std; int main() { int n, h[101] = {}; cin >> n; int A[100], max = 0; for (int i = 0; i < n; i++) cin >> A[i]; for (int i = 0; i < n; i++) { int B; cin >> B; h[B] += A[i]; if (max < h[B]) max = h[B]; } if (max == h[0]) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }