N = int(input()) A, B, C = map(int, input().split()) d = [A, B, C] d.sort() if A == C or B == C: exit(print("No")) if C < A < B or C > A > B: exit(print("No")) print("Yes")