unittest
{
	assert( [ "3", "1 3 2", "1 2 3" ].parse.expand.solve == "Yes" );
	assert( [ "3", "1 2 3", "2 2 2" ].parse.expand.solve == "No" );
	assert( [ "6", "3 1 2 6 3 4", "2 2 8 3 4 3" ].parse.expand.solve == "Yes" );
	
	assert( [ "4", "2 1 4 3", "1 2 3 4" ].parse.expand.solve == "Yes" );		// 追加ケース
	assert( [ "4", "2 3 4 1", "5 6 6 7" ].parse.expand.solve == "Yes" );		// 追加ケース
	assert( [ "6", "1 3 2 6 5 4", "6 5 4 3 2 1" ].parse.expand.solve == "No" );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	input.popFront;
	auto bs = input.front.split.to!( long[] );
	return tuple( as, bs );
}

auto solve( long[] as, long[] bs )
{
	zip( bs, as ).sort();
	auto aas = as.dup;
	auto aps = iota( as.length.signed ).array;
	zip( aas, aps ).sort();
	
	// 最適に並べ替えても as[i] <= bs[i] にならない場合は絶対No
	foreach( aa, b; lockstep( aas, bs ) )
	{
		if( b < aa ) return "No";
	}
	
	// 最適の状態からswapを1回減らせるならYes
	foreach( i; 1L .. aas.length.signed )
	{
		if( aas[ i ] <= bs[ i - 1 ] ) return "Yes";
	}
	
	// 最大でもN-1回のswapで全要素を並び替えられる
	// swap対象が2グループ以上に分けられるなら (NP[0]-1)+...+(NP[$-1]-1) < N-1 になるのでYes
	auto uft = UnionFindTree( as.length );
	foreach( ai, ap; aps )
	{
		uft.unite( ai, ap );
	}
	if( 2 <= uft.rootnum ) return "Yes";
	
	return "No";
}


// UnionFind木
struct UnionFindTree
{
	long[] ps;
	long[] rs;
	long   rn;
	
	this( long n )
	{
		ps.length = n;
		ps[] = -1;
		rs.length = n;
		rn = n;
	}
	
	long root( long i )
	{
		if( ps[ i ] < 0 ) return i;
		else              return ps[ i ] = root( ps[ i ] );
	}
	
	auto same( long i, long j )
	{
		return root( i ) == root( j );
	}
	
	auto unite( long i, long j )
	{
		i = root( i );
		j = root( j );
		if( i == j ) return;
		if( rs[ i ] < rs[ j ] )
		{
			ps[ j ] += ps[ i ];
			ps[ i ] = j;
		}
		else
		{
			ps[ i ] += ps[ j ];
			ps[ j ] = i;
			if( rs[ i ] == rs[ j ] ) rs[ i ]++;
		}
		rn--;
	}
	
	auto rootnum()
	{
		return rn;
	}
}
