main = interact $ unlines . map (ball 0 0 . map (read::String->Int) . words) . tail . lines
ball l r bs
 | null bs = "YES"
 | l < head bs && l >= r = ball (head bs) r (tail bs)
 | r < head bs = ball l (head bs) (tail bs)
 | otherwise = "NO"