electicode
HomeCoursesResourcesProblemsNational OlympiadContestsLeaderboard
...

Almost increasing

Time Limit: 1000msMemory Limit: 256MB
View Submissions

Problem Description

You are given an array aaa of length nnn.

In one operation, you can remove at most one element from the array (or not remove any).

Determine if it is possible to make the remaining sequence strictly increasing.

A sequence is called strictly increasing if
a1<a2<…<aka_1 < a_2 < \ldots < a_ka1​<a2​<…<ak​.

Input

The first line contains one integer nnn (1≤n≤2⋅105)(1 \le n \le 2 \cdot 10^5)(1≤n≤2⋅105) --- the length of the array.

The second line contains nnn integers a1,a2,…,ana_1, a_2, \ldots, a_na1​,a2​,…,an​
.

Output

Print YES if it is possible to remove at most one element so that the sequence becomes strictly increasing.
Otherwise, print NO.

Examples

Example 1
Input
5
1 2 3 4 5
Output
YES
Example 2
Input
5
1 2 10 3 4
Output
YES
Example 3
Input
4
1 3 2 1
Output
NO

© 2026 Electicode. All rights reserved.

(−109≤ai≤109)(-10^9 \le a_i \le 10^9)
(−109≤ai​≤109)