#include #include using namespace std; bool judge(vector &h, int n) { for (int i = 1; i < n; i++) { if (h[0] < h[i]) return false; } return true; } int main(void) { std::ios::sync_with_stdio(false); std::cin.tie(0); int N; int cnt = 0; cin >> N; vector point(N); vector hold(N); while (cnt < 2) { for (int i = 0; i < N; i++) { int n; cin >> n; if (cnt == 0) { point[i] = n; hold[i] = 0; } else { hold[n] += point[i]; } } cnt++; } cout << ((judge(hold, N)) ? "YES" : "NO") << endl; }