#include using namespace std; typedef long long ll; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) cin >> a[i]; int score[101] {}; int mx = 0; for (int i = 0; i < n; i++) { int b; cin >> b; score[b] += a[i]; mx = max(mx, score[b]); } if (score[0] == mx) puts("YES"); else puts("NO"); return 0; }