#include using namespace std; namespace { int X[ 110 ]; } int main() { int i; int b; int N; int A[ 110 ]; int K; cin >> N; for( i = 0; i < N; i++ ) cin >> A[ i ]; K = 0; for( i = 0; i < N; i++ ) { cin >> b; if( b == 0 ) K += A[ i ]; else X[ b ] += A[ i ]; } sort( A, A + N, greater() ); if( K >= A[ 0 ] ) cout << "YES" << endl; else cout << "NO" << endl; return 0; }