n = int(input()) a,b,c = map(int,input().split()) if a == c: print("No") exit() if a < b <= c or c <= b < a: print("Yes") else: print("No")