n = int(input()) a, b, c = map(int, input().split()) if (c - a) * (b - a) > 0: print("Yes") else: print("No")