import java.util.*; public class Main { static int[] questions; static boolean can = false; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = 7; questions = new int[n]; for (int i = 0; i < n; i++) { questions[i] = sc.nextInt(); } search(new boolean[n], new ArrayList()); if (can) { System.out.println("YES"); } else { System.out.println("NO"); } } static void search(boolean[] used, ArrayList list) { if (can) { return; } if (list.size() == 7) { for (int i = 0; i < 7 - 2; i++) { int a = list.get(i); int b = list.get(i + 1); int c = list.get(i + 2); if (a == b || b == c || c == a) { return; } if (a >= c) { return; } if ((b < a && b < c) || (b > a && b > c)) { } else { return; } } can = true; return; } for (int i = 0; i < 7; i++) { if (!used[i]) { used[i] = true; list.add(questions[i]); search(used, list); used[i] = false; list.remove(list.size() - 1); } } } }