#K7746. Adjusting Sequence to Non-Decreasing Order

    ID: 34869 Type: Default 1000ms 256MiB

Adjusting Sequence to Non-Decreasing Order

Adjusting Sequence to Non-Decreasing Order

You are given a sequence of n integers. Your task is to determine whether the sequence can be transformed into a non-decreasing sequence by modifying at most one element. In other words, check if it is possible to change at most one element so that for every adjacent pair \(a_i\) and \(a_{i+1}\), the condition \(a_i \le a_{i+1}\) holds.

Note: A sequence with a single element is always non-decreasing.

Example: For the sequence [4,2,3,4], the answer is "YES" because modifying the first element (or the second) can result in a non-decreasing sequence.

inputFormat

The first line contains an integer n representing the number of elements in the sequence.

The second line contains n space-separated integers representing the sequence.

outputFormat

Output a single line containing "YES" if the sequence can be transformed into a non-decreasing sequence by changing at most one element, otherwise output "NO".

## sample
4
4 2 3 4
YES

</p>