#K326. Strictly Increasing Sequence by Removing One Element

    ID: 24919 Type: Default 1000ms 256MiB

Strictly Increasing Sequence by Removing One Element

Strictly Increasing Sequence by Removing One Element

You are given an array of n integers. Your task is to determine whether it is possible to obtain a strictly increasing sequence by removing at most one element from the array.

A sequence \(a_1, a_2, \dots, a_n\) is considered strictly increasing if and only if \(a_1 < a_2 < \dots < a_n\). You are allowed to remove at most one element from the sequence to achieve this property.

For example, if the input sequence is [10, 1, 2, 3, 4] (with n = 5), by removing the first element (10) the sequence becomes [1, 2, 3, 4] which is strictly increasing. In contrast, in the sequence [5, 1, 2, 1] (with n = 4), no single removal can make the sequence strictly increasing.

inputFormat

The input is read from stdin and consists of two lines. The first line contains a single integer n representing the number of elements in the array. The second line contains n space-separated integers.

For example:

5
10 1 2 3 4

outputFormat

Output a single line to stdout containing either YES if it is possible to remove at most one element to make the list strictly increasing, or NO otherwise.

For example:

YES
## sample
5
10 1 2 3 4
YES

</p>