#arc102d. [arc102_d]Revenge of BBuBBBlesort!
[arc102_d]Revenge of BBuBBBlesort!
Problem Statement
You are given a permutation of : . Determine if the state where for every can be reached by performing the following operation any number of times:
- Choose three elements () such that and reverse the order of these three.
Constraints
- is a permutation of .
Input
Input is given from Standard Input in the following format:
Output
If the state where for every can be reached by performing the operation, print Yes
; otherwise, print No
.
Sample Input 1
5
5
2
1
4
3
Sample Output 1
Yes
The state where for every can be reached as follows:
- Reverse the order of . The sequence becomes .
- Reverse the order of . The sequence becomes .
Sample Input 2
4
3
2
4
1
Sample Output 2
No
Sample Input 3
7
3
2
1
6
5
4
7
Sample Output 3
Yes
Sample Input 4
6
5
3
4
1
2
6
Sample Output 4
No