input()
A=list(map(int,input().split()))
B=list(map(int,input().split()))
c=0
for i in range(len(A)):
    if A[i]<=B[i]:
        c+=1
    if sorted(A)[i]>sorted(B)[i]:
        print("No")
        exit()

print("Yes" if c>2 else "No")