713. Non-Decreasing Array

0

Easy

Kartik is fond of sorted arrays and wants to make an array sorted by performing only one operation. He requires your assistance with this problem. You are given an array called 'nums' with 'n' integers. Your task is to determine if it is possible to transform the array into a non-decreasing order by modifying at most one element. An array is considered non-decreasing if a[i] <= a[i + 1] holds true for every 'i' (0-based) such that 0 <= i <= n - 2. Print 'YES' if it is possible to transform the array into its sorted form; otherwise, print 'NO'.

Input Format

The first line contains an integer 'N' representing the size of the array. The second line contains 'N' space-separated integers representing the elements of the array.

Output Format

Print 'YES' if it is possible to transform the array into its sorted form; otherwise, print 'NO'.

Example

Input

3 4 2 5

Output

YES

Constraints

1 <= N <= 10^5 -10^5 <= Nums[i] <= 10^5
Loading...

View Submissions

Console