Byteasar bought his son Bytie a set of blocks numbered from 1 to n and placed them in a row in some order. Bytie wants to rearrange the blocks so that their numbers read in increasing order, from the smallest to the largest.
The only moves Bytie may use are:
Move b can only be used when there are at least 3 blocks. Given the initial arrangement, decide whether the blocks can be sorted into increasing order using any sequence of these two moves.
The first line contains a single integer n (1≤n≤2000).
The second line contains n distinct integers between 1 and n, separated by single spaces, giving the initial left-to-right arrangement of the blocks.
Print YES if the blocks can be sorted into increasing order using the allowed moves, or NO otherwise.