#include <bits/stdc++.h>
using namespace std;


int main() {
  int n;
  int data[10];
   while ( cin >> n ) {
     int flag = 1;
     for ( int i = 0; i < 10; i++ ) cin >> data[i];
     for ( int i = 0; i < 8; i++ ) {
       if ( data[i] > data[i+1] && 
	    data[i+1] > data[i+2] && data[i] > data[i+2] ) {
	 flag = 0;
       }
     }
     if ( flag ) cout << "YES" << endl;
     else cout << "NO" << endl;
  }
  return 0;
}