#include <iostream> #include <algorithm> using namespace std; bool iskadomatsu(int a, int b, int c) { return a!=c and ((b>a and b>c) or (b<a and b<c)); } int main() { vector<int> a(7); for(int& v: a) cin>>v; sort(begin(a), end(a)); do { bool ok=true; for(int i=0; i<5; ++i) { if (!(a[i]<a[i+2] and iskadomatsu(a[i], a[i+1], a[i+2]))) { ok=false; break; } } if (ok) { cout<<"YES"<<endl; return 0; } } while (next_permutation(begin(a), end(a))); cout<<"NO"<<endl; }