Given an array of n numbers, you are asked if you can sort it by removing at most a single element from it. Note the array is considered to be sorted if it’s ordered in both ascending and descending directions.
Input
The first line of the input contains a single integer n (1 ≤ n ≤ ) the number of elements in the array. The next line contains n integers separated by a space .
Output
The program should print Yes in case it’s possible to make the list sorted by removing at most a single element and No otherwise.
Examples
Input
Output
3
1 2 3
Yes
4
5 4 8 2
Yes
7
1 4 5 0 6 7 2
No
6
1 10 2 3 4 5
Yes
6
1 10 -1 20 30 40
Yes
6
1 10 -1 20 30 20
No
Hint
You can define a function that would check for the existence of a solution for ONLY the non-decreasing part. Then use the same function on the initial array and the reversed array.