import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import itertools *D, = map(int,read().split()) def is_kadomatsu(a,b,c): if a >= c: return False return (a > b < c) or (a < b > c) def is_kadomatsu_seq(A): return all(is_kadomatsu(a,b,c) for a,b,c in zip(A,A[1:],A[2:])) if any(is_kadomatsu_seq(p) for p in itertools.permutations(D)): answer = 'YES' else: answer = 'NO' print(answer)