#include int main (){ int N, i; int Q[100] = {0}, A[100] = {0}; int P[100] = {0}, K = 0, max = 0, max_i = 0; scanf("%d\n", &N); for(i = 0; i < N; i++){ scanf("%d ", &Q[i]); } for(i = 0; i < N; i++){ scanf("%d ", &A[i]); } for(i = 0; i < N; i++){ if(A[i] != 0){ P[A[i]] += Q[i]; }else{ K += Q[i]; } } max = P[0]; for(i = 0; i < 100; i++){ if(P[i] > max){ max = P[i]; max_i = i; } } //printf("max_i: %d max: %d K: %d\n", max_i, max, K); if(K >= max){ printf("YES\n"); }else{ printf("NO\n"); } return 0; }