DZY has a sequence a, consisting of n integers.

We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (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 only need to output the length of the subsegment you find.


-----Input-----

The first line contains integer n (1 ≤ n ≤ 10^5). The next line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9).


-----Output-----

In a single line print the answer to the problem — the maximum length of the required subsegment.


-----Examples-----
Input
6
7 2 3 1 5 6

Output
5



-----Note-----

You can choose subsegment a_2, a_3, a_4, a_5, a_6 and change its 3rd element (that is a_4) to 4.

Difficulty: competition

Starter code:

Solutions:
n=int(input())
vec=list(map(int,input().split()))
al=[]
otrez=[]
for x in vec:
    if len(al)==0:
        al.append(x)
    elif(x<=al[-1]):
        otrez.append(al)
        al=[x]
    else:
        al.append(x)
otrez.append(al)
maxx=0
if(len(otrez)!=1):
    for i in range(0,len(otrez)-1):
        if(len(otrez[i])==1)or(len(otrez[i+1])==1):
            maxot=len(otrez[i])+len(otrez[i+1])
        elif (otrez[i+1][0]-otrez[i][-2])>1 or (otrez[i+1][1]-otrez[i][-1])>1:
            maxot=len(otrez[i])+len(otrez[i+1])
        else:
            maxot=max([len(otrez[i]),len(otrez[i+1])])+1
        if(maxot>maxx):
            maxx=maxot
    print(maxx)
else:
    print(len(otrez[0]))


n=int(input())
a=input().split(' ')
a=[int (a) for a in a]
b=[-1 for b in range(0,n)]

now=0

while now<n:
    start=now
    while (now<n-1)and(a[now]<a[now+1]):
        now+=1
    while start<=now:
        b[start]=now
        start+=1

    now+=1
    start=now

ans=0

for i in range(0,n):
    if b[i]==n-1:
        ans=max(ans,b[i]-i+1)
    elif b[i]==n-2:
        ans=max(ans,b[i]-i+2)
    elif a[b[i]+2]-a[b[i]]>1:
        ans=max(ans,b[b[i]+2]-i+1)
    else:
        ans=max(ans,b[i]-i+2)
        if b[i]==0 or a[b[i]+1]-a[b[i]-1]>1:
            ans=max(ans,b[b[i]+1]-i+1)
    if i!=0 and n!=1 :
        ans=max(ans,b[i]-i+2)
print (ans)





import sys
#Length of the sequence
sequenceLength = int(sys.stdin.readline())
#populate sequence
sequence = list(map(int, sys.stdin.readline().split()))
#var for answer
ans = 0
#instantiate lists with 1's
leftList = [1] * sequenceLength
rightlist = [1] * sequenceLength
#create the left to right list of increasing
for i in range(1, sequenceLength):
    #if the last number is lesser
    if sequence[i - 1] < sequence[i]:
        #increment this number's count
        leftList[i] += leftList[i-1]
    #we are finding subseq's as we go, keep track of the biggest
    ans = max(ans, leftList[i])

#if the subseq isn't the size of the full array
#we can change a number before or after to fit
if ans < sequenceLength:
     ans += 1

#iterate from right to left, checking for decreasing
for i in range(sequenceLength - 2, 0, -1):
    #if it is decreasing increment
    if sequence[i + 1] > sequence[i]:
        rightlist[i] += rightlist[i + 1]

#print(leftList)
#print(rightlist)
#Go through the list from 1 to end
for i in range(1, sequenceLength - 1):
    #If there is a value between seq[i+1] and seq[i-1]
    if sequence[i+1] - sequence[i-1] >= 2:
        #if greater than last answer, set
        ans = max(ans, leftList[i - 1] + 1 + rightlist[i + 1])

print(ans)

n = int(input())
t = list(map(int, input().split()))
t.append(0)
p = [0] * (n + 1)
for i in range(n - 1):
    p[i + 1] = p[i] + 1 if t[i + 1] > t[i] else 0
s = max(p) + 2
if s >= n: print(n)
else:
    i = 1
    if p[i] == 0:
        if t[i + 1] > t[i - 1] + 1:
            d = p[i - 1] - 1
            i += 1
            while p[i]: i += 1
            s = max(s, d + p[i - 1] + 3)
        else: i += 1
    else: i += 1
    while i < n - 1:
        if p[i] == 0:
            if t[i] > t[i - 2] + 1: d = p[i - 2]
            elif t[i + 1] > t[i - 1] + 1: d = p[i - 1] - 1
            else:
                i += 1
                continue
            i += 1
            while p[i]: i += 1
            s = max(s, d + p[i - 1] + 3)
        else: i += 1
    print(s)

#input
n=int(input())
alist=[int(x) for x in input().split()]

#variables
maximum=2
l=[1]*n
r=l[:]

#main
if n<3:
	print(n)
	quit()

for i in range(0,n-1):
	if alist[i]<alist[i+1]:
		l[i+1]+=l[i]
	if alist[n-1-i]>alist[n-2-i]:
		r[n-2-i]+=r[n-1-i]

for i in range(1,n-1):
	if alist[i-1]+1<alist[i+1]:
		maximum=max(maximum,l[i-1]+r[i+1]+1)
	else:
		maximum=max(maximum,l[i-1]+1,r[i+1]+1)

maximum=max(maximum,r[1]+1,l[n-2]+1)

print(maximum)

ints = int(input())
nums = list(map(int, input().split(' ')))

if ints == 1:
    print(1)
elif ints == 2:
    print(2)
else:        
    left = [1]*ints
    right = [1]*ints

    #how many you can extend to the left
    #[1, 1, 2, 1, 2, 3]
    #the 3 can go to [1, 2, 3]
    #both 2s can go to [1, 2]
    for i in range(ints-1):
        if nums[i+1] > nums[i]:
            left[i+1] += left[i]

    #how many you can extend to the right
    #the 2nd 1 can go to [1, 2]
    #the 3rd 1 can go to [1, 2, 3]
    nums.reverse()
    for i in range(ints-1):
        if nums[i+1] < nums[i]:
            right[i+1] += right[i]

    nums.reverse()
    right.reverse()

    maximum = 2
    for i in range(1, ints-1):
        if nums[i-1]+1 < nums[i+1]:
            maximum = max(maximum, left[i-1] + right[i+1] + 1)
        else:
            maximum = max(maximum, max(left[i-1]+1, right[i+1]+1))

    maximum=max(maximum, left[ints-2]+1, right[1]+1)
    print(maximum)


n = int(input())
a = list(map(int, input().split())) + [0]
s, sb, val = [], 0, 0
for i in range(1, n + 1):
    if a[i] <= a[i - 1]:
        s.append((sb, i - 1))
        val = max(val, i - sb)
        sb = i
val += len(s) > 1
for i in range(1, len(s)):
    c = s[i][0]
    if c in range(2, n - 1) and max(a[c] - a[c - 2], a[c + 1] - a[c - 1]) >= 2:
        val = max(val, s[i][1] - s[i - 1][0] + 1)
print(val)


def main():
	n = int(input())
	
	a = [10 ** 10] + list(map(int, input().split())) + [-(10 ** 10)]
	if n == 1:
		print(1)
		return
	b = [0] * (n + 10)
	c = [0] * (n + 10)
	#print(a, b, c)
	i = 1
	while i <= n:
		for j in range(i, n+1):
			if a[j] >= a[j+1]:
				break
		for k in range(i, j+1):
			b[k] = i
			c[k] = j
		i = j + 1
	#print(c,b)
	ans = max(c[2], n - b[n-1] + 1, c[1], n - b[n] + 1)
	for i in range(2, n):
		ans = max(ans, c[i] - i + 2, i - b[i] + 2)
		if a[i - 1]+ 1 < a[i+1]:
			ans = max(ans, c[i+1] - b[i-1] + 1)
	print(ans)


def __starting_point():
	main()

__starting_point()

n = int(input())

sequence = [float('-inf')] + [int(i) for i in input().split()] + [float('inf')]

f1 = [0] * n
f2 = [0] * n
f3 = [True if sequence[i + 1] - sequence[i - 1] >
      1 else False for i in range(1, len(sequence) - 1)]
len_1 = 0
len_2 = 0

l = len(sequence) - 1
for i in range(1, len(sequence) - 1):
    f1[i-1] = len_1
    f2[i-1] = len_2
    if sequence[i] > sequence[i - 1]:
        len_1 += 1
    else:
        len_1 = 1
    if sequence[l - i] < sequence[l - i + 1]:
        len_2 += 1
    else:
        len_2 = 1

f2 = f2[::-1]

f = [f1[i] + f2[i] + 1 if f3[i]
     else max(f1[i], f2[i]) + 1 for i in range(0, n)]

max_len = max(f)

print(max_len)

'''
n = int(input())

sequence = [float('-inf')] + [int(i) for i in input().split()] + [float('inf')]

len_1 = 1
len_2 = 0
max_len = 1

i = 1
while(i < n):
    if sequence[i] < sequence[i + 1]:
        len_1 += 1
        i += 1
    else:
        l = len_1 + len_2 + 1
        if l > max_len:
            max_len = l
        len_1, len_2 = 1, len_1

        if sequence[i + 2] - sequence[i] <= 1:
            if sequence[i + 1] - sequence[i - 1] > 1:
                len_2 -= 1
            else:
                len_2 = 0
            i += 1
        else:
            i += 2

if max_len < len_1 + len_2 + 1:
    max_len = len_1 + len_2 + 1

if max_len > n:
    max_len = n

print(max_len)
'''



n = int(input())
arr = [int(i) for i in input().split(' ')]
a = []

last = 0
running_length = 0

for i in arr:
    if i > last:
        running_length += 1
    else:
        a.append(running_length)
        running_length = 1
    last = i

if running_length > 0:
    a.append(running_length)

def canjoin(en, begin):
    if begin == len(a) - 1:
        return True
    return arr[en - 1] < arr[begin] - 1 or arr[en] < arr[begin+1] - 1

best = max(a) + 1 if max(a) != len(arr) else len(arr)
start = 0
for i in range(len(a)-1):
    end = start + a[i] - 1

    if end == len(arr) - 1:
        best = max(best, a[i]);
    else:
        if a[i+1] == 1 and end+1 != len(arr) - 1:
            # 3 seq joins
            if arr[end] < arr[end+2] - 1:
                best = max(best, a[i] + a[i+2])

        if a[i] == 1 or a[i+1] == 1 or canjoin(end, end+1):
            best = max(best, a[i] + a[i+1])

    start = end + 1

print(best)


n=int(input())
a=list(map(int,input().split()))
pre=[1]*n
suf=[1]*n
for i in range(1,n):
    if a[i]>a[i-1]:
        pre[i]=pre[i-1]+1
for i in range(n-2,0,-1):
    if a[i]<a[i+1]:
        suf[i]=suf[i+1]+1
ans=max(pre)
for i in range(0,n):
    if i>0:
        ans=max(ans,pre[i-1]+1)
    if i<n-1:
        ans=max(ans,suf[i+1]+1)
    if i>0 and i<n-1 and a[i-1]<=a[i+1]-2:
        ans=max(ans,pre[i-1]+suf[i+1]+1)
print(ans)

def main():
    n, l, res, a = int(input()), [], [], 0
    aa = list(map(int, input().split()))
    for i, b in enumerate(aa):
        if a >= b:
            l.append(i)
        a = b
    if not l:
        print(n)
        return 
    l.append(n)
    rapp, a = res.append, 0
    for b in l:
        rapp(b - a)
        a = b
    a = b = 0
    for c in l:
        if a + 1 < b < c - 1 and (aa[b] - aa[b - 2] > 1 or aa[b + 1] - aa[b - 1] > 1):
            rapp(c - a - 1)
        a, b = b, c
    print(max(res) + 1)


def __starting_point():
    main()

__starting_point()

from sys import stdin, stdout
n = int(stdin.readline())
a = [int(s) for s in stdin.readline().split()]
left = [0 for i in range(n)]
right = [0 for i in range(n)]

left[0] = 1
for i in range(1, n):
    if a[i] > a[i-1]:
        left[i] = left[i-1] + 1
    else:
        left[i] = 1

right[n-1] = 1
for i in range(n-2,-1,-1):
    if a[i] < a[i+1]:
        right[i] = right[i+1] + 1
    else:
        right[i] = 1

ans = 0

for i in range(1,n-1):
    if a[i+1]-a[i-1]>1:
        ans = max(ans, left[i-1]+1+right[i+1])
    else:
        ans = max(ans, left[i-1]+1, right[i+1]+1)
if n > 1:
    ans = max(ans, 1 + right[1], 1 + left[n-2])
else:
    ans = 1
stdout.write(str(ans))


n = int(input())
a = list(map(int, input().split()))

INF = 10 ** 9

dp = [[-INF] * 3 for i in range(n)]
for i in range(n):
    dp[i][0] = dp[i][2] = 1
    if i > 0:
        dp[i][1] = 2


def upd(i, cr, nx):
    dp[i + 1][nx] = max(dp[i + 1][nx], dp[i][cr] + 1)


for i in range(n - 1):
    for j in range(3):
        cur = dp[i][j]

        if j == 0:
            if a[i + 1] > a[i]:
                upd(i, j, 0)
                upd(i, j, 2)
            else:
                upd(i, j, 2)
        elif j == 1:
            if a[i + 1] > a[i]:
                upd(i, j, 1)
        else:
            if i > 0 and a[i + 1] > a[i - 1] + 1:
                upd(i, j, 1)


ans = 0
for i in range(n):
    ans = max(ans, max(dp[i]))

print(ans)


# http://codeforces.com/contest/446/problem/A

from sys import stdin
inFile = stdin
tokens = []
tokens_next = 0

def next_str():
    nonlocal tokens, tokens_next
    while tokens_next >= len(tokens):
        tokens = inFile.readline().split()
        tokens_next = 0
    tokens_next += 1
    return tokens[tokens_next - 1]

def nextInt():
    return int(next_str())

def nextIncreasingSeg(a, ind):
	if ind >= len(a):
		return None
	r = ind
	while r + 1 < len(a) and a[r + 1] > a[r]:
		r += 1
	return (ind, r)

def myLen(s):
	return s[1] - s[0] + 1

def getBest(a, s0, s1):
	if not s1:
		return myLen(s0)

	if s0[1] - 1 >= s0[0]:
		if a[s0[1] - 1] < a[s1[0]] - 1:
			return myLen(s0) + myLen(s1)
	
	if s1[0] + 1 <= s1[1]:
		if a[s1[0] + 1] > a[s0[1]] + 1:
			return myLen(s0) + myLen(s1)
	return 1 + max(myLen(s0), myLen(s1))

n = nextInt()
a = [nextInt() for i in range(n)]

s0 = nextIncreasingSeg(a, 0)
s1 = nextIncreasingSeg(a, s0[1] + 1)
res = getBest(a, s0, s1)

while s1 and s1[1] + 1 < len(a):
	s0, s1 = s1, nextIncreasingSeg(a, s1[1] + 1)
	res = max(res, getBest(a, s0, s1))

print(res)


n = int(input())
a = [int(i) for i in input().split()]
l,r = [1]*n,[1]*n

for i in range(1,n):
    if a[i-1]<a[i]: l[i]+=l[i-1]

for i in range(n-2,0,-1):
    if a[i+1]>a[i]: r[i]+=r[i+1]

ans = max(l)
if ans<n: ans+=1
for i in range(1,n-1):
    if a[i-1]+1<a[i+1]: ans=max(ans,l[i-1]+r[i+1]+1)
print(ans)

n=int(input())
l=[1]*n
r=[1]*n
a= list(map(int,input().split()))
for i in range(1,n):
 if a[i-1]<a[i]:
  l[i]+=l[i-1]
for i in range(n-2,-1,-1):
 if a[i]< a[i+1]:
  r[i]+=r[i+1]

ans=max(l)
if ans<n:
 ans+=1
#print(l)
#print(r)
for i in range(1,n-1):
 if a[i-1]+1 < a[i+1]:
 	ans=max(ans,l[i-1]+1+r[i+1])
 else:
    ans= max(ans,l[i-1]+1)
 #print(ans)
print(ans)
  
  


def solve():
    size = int(input())
    ls = list(map(int, input().rstrip().split()))
    dp0 = [1 for i in range(size)]
    dp1 = [1 for i in range(size)]
    for i in range(1, size):
        dp0[i] = dp0[i - 1] + 1 if (ls[i - 1] < ls[i]) else 1 
    for i in range(0, size - 1)[::-1]:
        dp1[i] = dp1[i + 1] + 1 if (ls[i + 1] > ls[i]) else 1
    best = max(max(dp0), max(dp1))
    for i in range(0, size):
        if i >= 1:
            best = max(best, dp0[i - 1] + 1)
        if i <= size - 2:
            best = max(best, dp1[i + 1] + 1)
        if i <= size - 2 and i >= 1:
            if ls[i - 1] + 1 < ls[i + 1]:
                best = max(best, dp0[i - 1] + dp1[i + 1] + 1)
    return best

def __starting_point():
    print(solve())

__starting_point()

elems = int(input())
data = list(map(int, input().split()))
data.append(float("-inf"))

def find_seq_breaks():
    nonlocal elems
    nonlocal data
    seq_spans = []
    sequence_idx = 0
    longest_span = 0
    for i in range(1, elems + 1):
        if data[i] <= data[i - 1]:
            seq_range = [sequence_idx, i - 1]
            seq_spans.append(seq_range)

            diff = i - sequence_idx
            if (longest_span < diff):
                longest_span = diff

            sequence_idx = i
    return (seq_spans, longest_span)

def parse_seqs(seq_spans, longest_span):
    nonlocal data
    nonlocal elems

    if len(seq_spans) > 1:
        longest_span += 1

    for i in range(1, len(seq_spans)):
        one_past = seq_spans[i][0]
        if one_past >= 2 or one_past <= elems - 1:
            #look at values before and after num that broke seq
            r = data[one_past] - data[one_past-2]
            r2 = data[one_past + 1] - data[one_past - 1]
            candidate = seq_spans[i][1] - seq_spans[i - 1][0] + 1
            if r >= r2:
                if r >= 2:
                   if longest_span < candidate:
                       longest_span = candidate
            elif r2 >= 2:
                if r2 >= 2:
                    if longest_span < candidate:
                        longest_span = candidate
    return longest_span

d = find_seq_breaks()
print(parse_seqs(d[0], d[1]))


n = int(input())
inp = list(map(int, input().split()))

input_parse = []
dp = []
for i in inp:
    if len(input_parse) == 0:
        input_parse.append(i)
    elif i <= input_parse[-1]:
        dp.append(input_parse)
        input_parse = [i]
    else:
        input_parse.append(i)

dp.append(input_parse)
optimum = 0
if len(dp) != 1:
    for i in range(len(dp) - 1):
        if len(dp[i]) == 1 or len(dp[i+1]) == 1:
            curr_opt = len(dp[i]) + len(dp[i+1])
        elif dp[i + 1][0] - dp[i][-2] > 1 or  dp[i + 1][1] - dp[i][-1] > 1:
            curr_opt= len(dp[i]) + len(dp[i+1])
        else:
            curr_opt=max(len(dp[i]), len(dp[i+1])) + 1
        if curr_opt > optimum:
            optimum = curr_opt
    print(optimum)
else:
    print(len(dp[0]))


from copy import copy

length = int(input())
nums= input().split(" ")
numsList = []

for n in nums:
    numsList.append(int(n))

left = []
right = []

for i in range(length):
    left.append(1)
    right.append(1)
    
for i in range(1, length):
    if numsList[i] > numsList[i-1]:
        left[i] = left[i-1] + 1
    if numsList[length-i] > numsList[length-i-1]:
        right[length-i-1] = right[length-i] + 1

answer = 0
for i in range(length):
    if length == 1:
        answer = 1
    elif i == 0:
        if left[i] == 1:
            maxVal = right[i+1] + left[i] 
            if maxVal > answer:
                answer = maxVal
#         if right[i] == 1:
#             maxVal = right[i+1] + left[i] 
#             if maxVal > answer:
#                 answer = maxVal
    elif i == length-1:
        if left[i] == 1:
            maxVal = left[i-1] + right[i]
            if maxVal > answer:
                answer = maxVal
    else:
        if left[i] == 1:
            if (numsList[i+1] - numsList[i-1] >= 2 or (i-2 > 0 and numsList[i] - numsList[i-2] >= 2)):
                maxVal = left[i-1] + right[i]
                if maxVal > answer:
                    answer = maxVal
            else:
                maxVal = left[i-1] + 1
                if maxVal > answer:
                    answer = maxVal
        if right[i] == 1:
            if (numsList[i+1] - numsList[i-1] >= 2 or (i+2 < length and numsList[i+2] - numsList[i] >= 2)):
                maxVal = right[i+1] + left[i]
                if maxVal > answer:
                    answer = maxVal
            else:
                maxVal = right[i+1] + 1
                if maxVal > answer:
                    answer = maxVal

print (answer)



from collections import deque
from sys import stdin
lines = deque(line.strip() for line in stdin.readlines())

def nextline():
    return lines.popleft()

def types(cast):
    return tuple(int(x) for x in nextline().split())

def ints():
    return types(int)

def strs():
    return nextline().split()

def main():
    # lines will now contain all of the input's lines in a list
    (n,) = ints()
    nums = ints()
    if n == 1:
        return n
    inc = [1]*n
    for i in range(1, n):
        if nums[i] > nums[i-1]:
            inc[i] = inc[i-1]+1
    dec = [1]*n
    for i in range(n-2, -1, -1):
        if nums[i] < nums[i+1]:
            dec[i] = dec[i+1]+1
    m = max(inc[n-2], dec[1])+1
    for i in range(1, n-1):
        if nums[i-1]+1 < nums[i+1]:
            length = inc[i-1]+dec[i+1]+1
        else:
            length = max(inc[i-1], dec[i+1])+1
        if length > m:
            m = length
    return m

def __starting_point():
    print(main())

__starting_point()

n = int(input())
seq = [int(n) for n in input().split()]
dp = [0 for n in range(n+1)]
for j in range(0, n):
    if(seq[j] > seq[j-1]):
        dp[j] = (dp[j-1] + 1)
    else:
        dp[j] = 1
seq.append(0)

m = 0
x = 0
for i in range(n-1, -1, -1):
    m = max(m, dp[i-1] + 1, x + 1)
    if(i == 0 or i == n-1 or seq[i-1] + 1 < seq[i+1]):
        m = max(m, dp[i-1] + x + 1)
        
    if(seq[i] < seq[i+1]):
        x += 1
    else:
        x = 1
        
print(m)

n = int(input())
a = [int(x) for x in input().split()]

l, r = 0, 0
c = None
mx = 1

while r < n - 1:
    r += 1
    
    if a[r] <= (a[r - 1] if r - 1 != c else a[r - 2] + 1):
        if c is not None and r - 1 == c and a[r - 1] < a[r]:
            if a[c] < a[c + 1]:
                l = c = c - 1
            else:
                l = c
        else:
            if c is not None:
                if a[c] < a[c + 1]:
                    l = c
                else:
                    l = c + 1
            
            if r - 1 == l or a[r] - a[r - 2] > 1:
                c = r - 1
            else:
                c = r
    
    mx = max(mx, r - l + 1)

print(mx)