PROGRAMMING:Search tree judgment
For binary search tree, we stipulate that the left subtree of any node only contains the key value which is strictly less than the node, while the right subtree contains the key value which is greater than or equal to the node. If we exchange the left and right subtrees of each node, the resulting tree is called mirror binary search tree.
Now we give an integer key value sequence. Please write a program to judge whether the sequence is the preorder traversal sequence of a binary search tree or a mirror binary search tree. If it is, the postorder traversal sequence of the corresponding binary tree will be output.
###Input format:
The first line of input contains a positive integer n ($$$Le $$1000), and the second line contains n integers. It is the given integer key value sequence, and the numbers are separated by spaces.
###Output format:
The first line of the output first gives the judgment result. If the input sequence is the preorder traversal sequence of a binary search tree or a mirror binary search tree, output 'yes', and output' no '. If the judgment result is' yes', the next line outputs the post traversal sequence of the corresponding binary tree. Numbers are separated by spaces, but there should be no extra spaces at the end of the line.
###Input sample 1:
```in
seven
8 6 5 7 10 8 11
```
###Output sample 1:
```out
YES
5 7 6 8 11 10 8
```
###Input sample 2:
```
seven
8 6 8 5 10 9 11
```
###Output sample 2:
```
NO
```
answer:If there is no answer, please comment
Now we give an integer key value sequence. Please write a program to judge whether the sequence is the preorder traversal sequence of a binary search tree or a mirror binary search tree. If it is, the postorder traversal sequence of the corresponding binary tree will be output.
###Input format:
The first line of input contains a positive integer n ($$$Le $$1000), and the second line contains n integers. It is the given integer key value sequence, and the numbers are separated by spaces.
###Output format:
The first line of the output first gives the judgment result. If the input sequence is the preorder traversal sequence of a binary search tree or a mirror binary search tree, output 'yes', and output' no '. If the judgment result is' yes', the next line outputs the post traversal sequence of the corresponding binary tree. Numbers are separated by spaces, but there should be no extra spaces at the end of the line.
###Input sample 1:
```in
seven
8 6 5 7 10 8 11
```
###Output sample 1:
```out
YES
5 7 6 8 11 10 8
```
###Input sample 2:
```
seven
8 6 8 5 10 9 11
```
###Output sample 2:
```
NO
```
answer:If there is no answer, please comment