
A train is approaching a dead-end from track (see illustration). You are allowed to detach one or more of the leading railcars from the train and move them into the dead-end (if you wish, the entire train can be moved into the dead-end at once). After that, some of these railcars can be moved out onto track . Next, you may move more railcars from the train into the dead-end, and again move some from the dead-end onto track . This process continues, with the conditions that every railcar can enter the dead-end from track only once and exit onto track only once. It is forbidden to enter the dead-end from track , or to leave the dead-end onto track . Moving directly from track to track without entering the dead-end is not allowed.
The initial order of the train's railcars is known. Using the operations described, you must arrange the railcars in strictly increasing order (first car, then the second, and so on, numbered from the front of the train going along track away from the dead-end). Write a program to determine if this is possible.
The first line contains the number of railcars (1 \le n \le 100). The following line contains the numbering of the railcars, in order from the head of the train going along track towards the dead-end. The railcars are numbered consecutively from to , each number appears exactly once.
If it is possible to rearrange the cars in order from to , starting from the head on track moving away from the dead-end, output YES. Otherwise, output NO.
Example 1
Example 2
Example 3