process.stdin.on("data",function(c){
	(c+"").trim().split("\n").slice(1).some(function(a){
		a=a.split(" ");
		var b=0,c=0;
		console.log(a.some(function(n){
			return b<(n=+n)?(b=n,0):c<n?(c=n,0):1;
		})?"NO":"YES");
	});
}).resume();