import java.util.*; public class Main_yukicoder360 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] d = new int[7]; for (int i = 0; i < 7; i++) { d[i] = sc.nextInt(); } int[] tmp = new int[3]; Permutation np = new Permutation(7); for (List perm : np) { // System.out.println(perm); if (perm == null) { break; } boolean flag = true; for (int i = 0; i < 5; i++) { tmp[0] = d[perm.get(i + 0)]; tmp[1] = d[perm.get(i + 1)]; tmp[2] = d[perm.get(i + 2)]; if (tmp[2] <= tmp[0] || !isKado(tmp)) { flag = false; break; } } if (flag) { System.out.println("YES"); sc.close(); return; } } System.out.println("NO"); sc.close(); } private static boolean isKado(int[] a) { if (a[0] == a[1] || a[1] == a[2] || a[2] == a[0]) { return false; } if (a[1] > a[0] && a[1] > a[2]) { return true; } if (a[1] < a[0] && a[1] < a[2]) { return true; } return false; } private static class Permutation implements Iterable>{ int n; boolean[] used; List perm; Deque ist; PermutationIterator it; Permutation(int n) { this.n = n; used = new boolean[n]; perm = new ArrayList(); ist = new ArrayDeque(); ist.add(-1); it = new PermutationIterator(this); } List next() { out: while (!ist.isEmpty()) { int k = ist.pop(); if (k != -1) { // ループ途中での戻り used[k] = false; perm.remove(perm.size() - 1); } else { // 最初から int pos = perm.size(); if (pos == n) { // perm に対する操作 ========================= return perm; // perm に対する操作 ========================= } } for (int i = k + 1; i < n; i++) { if (!used[i]) { ist.push(i); used[i] = true; perm.add(i); ist.push(-1); continue out; } } } return null; } @Override public Iterator> iterator() { return it; } private static class PermutationIterator implements Iterator> { Permutation p; PermutationIterator(Permutation p) { this.p = p; } @Override public boolean hasNext() { return !p.ist.isEmpty(); } @Override public List next() { return p.next(); } } } }