#K70722. Non-decreasing Array Modification

    ID: 33372 Type: Default 1000ms 256MiB

Non-decreasing Array Modification

Non-decreasing Array Modification

You are given an array of integers. Your task is to determine whether it is possible to modify at most one element of the array so that the resulting sequence is non-decreasing. In other words, after at most one modification, the array should satisfy:

a1a2ana_1 \le a_2 \le \cdots \le a_n

If it is possible, print YES; otherwise, print NO.

Note: Modification means changing the value of an element to any integer.

inputFormat

The input consists of two lines:

  • The first line contains a single integer n (the number of elements in the array).
  • The second line contains n space-separated integers representing the array.

outputFormat

Output a single line with YES if the array can be made non-decreasing by modifying at most one element, or NO otherwise.

## sample
3
4 2 3
YES

</p>