from itertools import permutations D = list(map(int,input().split())) for X in permutations(range(7),7): for i in range(5): Y = [D[X[i]],D[X[i+1]],D[X[i+2]]] if (max(Y) == Y[1] or min(Y) == Y[1]) and Y[0] < Y[2]: continue else: break else: print("YES") exit() print("NO")