#include<iostream>

using namespace std;

int tama[10];

bool Haireruka(int i,int left,int right){
	if(tama[i]<left){
		if(Haireruka(i+1,tama[i],right))return true;
	}
	if(tama[i]<right){
		if(Haireruka(i+1,left,right))return true;
	}
	return false;
}

int main(){
	for(int i=0;i<10;i++){
		cin>>tama[i];
	}
	if(Haireruka(0,0,0))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}