#include<iostream>
using namespace std;
int main(){
	int ball;
	int n;
	while(cin >> n){
		bool flag = true;
		int B=0, C=0;
		for(int i=0; i<10; i++){
			cin >> ball;
			if(flag){
				if(B < ball) B=ball;
				else if(C < ball) C=ball;
				else flag=false;
			}
		}
		if(flag) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}