Increasing Subsegment

Gary has a sequence A, consisting of n integers.

We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.

Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change one number to any integer you want) from the subsegment to make the subsegment strictly increasing. You need to return the length of the maximum subsegment that you can find by changing only one integer in the given sequence.

Input Format :

Line 1 : Integer n (1 ≤ n ≤ 10^5)

Line 2 : n integers a1, a2, ..., an (1 ≤ ai ≤ 10^9).

Output Format :

You only need to return the length of the subsegment you find.

Sample Input :

1 4 3 4

Sample Output :


Login to submit your solution

Fb dab53a1a64929320dc7425896aa73fd9e5512b6ab52e414ff5f3ebb5cecc73eb

Share Problem