import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int[] D = new int[8]; for (int i = 1; i <= 7; i++) { D[i] = scanner.nextInt(); } System.out.println(new Solver().solve(D)); } } class Solver { public String solve(int[] d) { if (isZoukaKadomatsu(d)) { return "YES"; } ArrayList list = new ArrayList<>(); list.add(0); if (dfs(0, d, new boolean[8], list)) { return "YES"; } return "NO"; } private boolean dfs(int i, int[] d, boolean[] bs, ArrayList list) { bs[i] = true; if (all(bs)) return true; for (int j = 1; j <= 7; j++) { if (bs[j]) continue; boolean[] newbs = Arrays.copyOf(bs, bs.length); ArrayList newlist = new ArrayList<>(list); newlist.add(d[j]); int[] is = new int[newlist.size()]; for (int k = 0; k < newlist.size(); k++) { is[k] = newlist.get(k); } if (isZoukaKadomatsu(is)) { if (dfs(j, d, newbs, newlist)) { return true; } } } return false; } private boolean all(boolean[] bs) { for (boolean b : bs) { if (!b) return false; } return true; } private boolean isZoukaKadomatsu(int[] d) { for (int i = 1; i < d.length - 2; i++) { if (!isKadomatsu(d[i], d[i + 1], d[i + 2])) { return false; } } return true; } private boolean isKadomatsu(int i, int j, int k) { if (i == j || i == k || j == k) return false; if (i > k) return false; return (j > i && j > k) || (j < i && j < k); } }