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.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Dynamic programming

Amortized analysis

Implementation


Solutions:
import sys
sequenceLength = int(sys.stdin.readline())
sequence = list(map(int, sys.stdin.readline().split()))
ans = 0
leftList = [1] * sequenceLength
rightlist = [1] * sequenceLength
for i in range(1, sequenceLength):
	if sequence[i - 1] < sequence[i]:
		leftList[i] += leftList[i - 1]
	ans = max(ans, leftList[i])
if ans < sequenceLength:
	ans += 1
for i in range(sequenceLength - 2, 0, -1):
	if sequence[i + 1] > sequence[i]:
		rightlist[i] += rightlist[i + 1]
for i in range(1, sequenceLength - 1):
	if sequence[i + 1] - sequence[i - 1] >= 2:
		ans = max(ans, leftList[i - 1] + 1 + rightlist[i + 1])
print(ans)


import random, math, sys, os, heapq
from bisect import bisect_left, bisect_right
from collections import Counter
from io import BytesIO, IOBase
input = sys.stdin.readline

def findLISubarray(li, n, func):
	dp = [1 for i in range(n)]
	for i in range(1, n):
		if func(li[i - 1], li[i]):
			dp[i] += dp[i - 1]
	return dp

def solution(li, n):
	if n <= 2:
		return n
	dp = findLISubarray(li, n, lambda x, x1: x < x1)
	li.reverse()
	dpRev = findLISubarray(li, n, lambda x, x1: x > x1)
	dpRev.reverse()
	li.reverse()
	maxi = 2
	for i in range(n - 2):
		if li[i + 2] - li[i] > 1:
			maxi = max(maxi, dp[i] + dpRev[i + 2] + 1)
	return min(max(maxi, max(dp) + 1), n)

def input_test():
	n = int(input())
	li = list(map(int, input().strip().split(' ')))
	print(solution(li, n))

def test():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
input_test()


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)


length = int(input())
nums = [int(num) for num in input().split()] + [float('inf'), float('-inf')]
ans = 0
small = 0
big = 0
for i in range(length):
	if nums[i] > nums[i - 1]:
		small += 1
		big += 1
	else:
		ans = max(ans, small + 1, big)
		big = small + 1 if nums[i + 1] > nums[i - 1] + 1 or nums[i] > nums[i - 2] + 1 else 2
		small = 1 if nums[i + 1] > nums[i] else 0
ans = max(ans, big)
print(ans)


n = int(input())
arr = list(map(int, input().split()))
(pre, pre1) = ([1], [1])
for i in range(1, n):
	if arr[i] > arr[i - 1]:
		pre.append(pre[-1] + 1)
	else:
		pre.append(1)
arr.reverse()
for i in range(1, n):
	if arr[i] < arr[i - 1]:
		pre1.append(pre1[-1] + 1)
	else:
		pre1.append(1)
pre1.reverse()
arr.reverse()
ans = 1
for i in range(n):
	if i > 0 and i < n - 1 and (arr[i - 1] < arr[i + 1] - 1):
		ans = max(ans, pre[i - 1] + pre1[i + 1] + 1)
	if i > 0:
		ans = max(ans, pre[i - 1] + 1)
	if i < n - 1:
		ans = max(ans, pre1[i + 1] + 1)
print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
l = list(map(int, input().split()))
a = 0
b = 0
i = 0
l1 = []
while i < n - 1:
	if l[i] < l[i + 1]:
		b += 1
		i += 1
	else:
		l1.append([a, b])
		a = b + 1
		b = b + 1
		i += 1
if a < n - 1:
	l1.append([a, n - 1])
else:
	l1.append([n - 1, n - 1])
l2 = []
for i in l1:
	l2.append(i[1] - i[0] + 1)
ans = 1
if len(l1) == 1:
	print(l1[0][1] - l1[0][0] + 1)
else:
	for i in range(len(l1) - 1):
		if l2[i] == 1 or l2[i + 1] == 1:
			ans = max(ans, l2[i] + l2[i + 1])
		else:
			a = l1[i]
			b = l1[i + 1]
			if l[a[1]] + 1 < l[b[0] + 1] or l[a[1] - 1] + 1 < l[b[0]]:
				ans = max(ans, l2[i] + l2[i + 1])
			else:
				ans = max(ans, l2[i] + 1, l2[i + 1] + 1)
	print(ans)


N = int(input())
if N > 1:
	a = list(map(int, input().split()))
	b = a[::-1]
	a.append(10 ** 20)
	b.append(0)
	r = 0
	dp = [0 for i in range(N)]
	for l in range(N):
		while r < N and a[r] < a[r + 1]:
			r += 1
		if l == r:
			dp[l] = 1
			r += 1
		elif l < r:
			if r != N:
				dp[l] = r - l + 1
			else:
				dp[l] = r - l
	r = 0
	dpr = [0 for i in range(N)]
	for l in range(N):
		while r < N and b[r] > b[r + 1]:
			r += 1
		if l == r:
			dpr[l] = 1
			r += 1
		elif l < r:
			if r != N:
				dpr[l] = r - l + 1
			else:
				dpr[l] = r - l
	ans = 0
	for i in range(N):
		if i == 0:
			ans = max(ans, dp[1] + 1)
		elif i == N - 1:
			ans = max(ans, dpr[1] + 1)
		elif a[i - 1] + 1 < a[i + 1]:
			ans = max(ans, dp[i + 1] + dpr[N - i] + 1)
		elif a[i - 1] + 1 >= a[i + 1]:
			ans = max(ans, dp[i + 1] + 1, dpr[N - i] + 1)
	print(ans)
else:
	print(1)


n = int(input())
A = [int(ele) for ele in input().split(' ')]
if n <= 2:
	print(n)
else:
	LISend = [1] * n
	LISbegin = [1] * n
	for i in range(1, n):
		if A[i] > A[i - 1]:
			LISend[i] = LISend[i - 1] + 1
	for i in range(n - 2, -1, -1):
		if A[i] < A[i + 1]:
			LISbegin[i] = LISbegin[i + 1] + 1
	maxLength = 0
	for i in range(1, n - 1):
		if A[i + 1] - A[i - 1] >= 2:
			maxLength = max(LISend[i - 1] + 1 + LISbegin[i + 1], maxLength)
	maxLength = max(LISbegin[1] + 1, maxLength)
	maxLength = max(LISend[n - 2] + 1, maxLength)
	maxLength = max(min(n, max(LISbegin) + 1), maxLength)
	print(maxLength)


n = int(input())
a = [int(x) for x in input().split()]
res = [[0], []]
cur = 1
for i in range(1, n):
	res[0].append(cur)
	if a[i - 1] < a[i]:
		cur += 1
	else:
		cur = 1
cur = 1
for i in range(n - 2, -1, -1):
	res[1].append(cur)
	if a[i + 1] > a[i]:
		cur += 1
	else:
		cur = 1
res[1] = res[1][::-1] + [0]
fin = max(max(res[1][0] + 1, res[0][-1] + 1), 2)
for i in range(1, n - 1):
	fin = max(fin, max(res[0][i] + 1, res[1][i] + 1))
	if a[i - 1] + 1 < a[i + 1]:
		fin = max(fin, res[0][i] + res[1][i] + 1)
print(min(n, fin))


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


n = int(input())
l = list(map(int, input().split(' ')))
a = [1] * n
b = [1] * n
for i in range(1, n):
	if l[i] > l[i - 1]:
		a[i] = a[i - 1] + 1
i = n - 2
while i >= 0:
	if l[i + 1] > l[i]:
		b[i] = b[i + 1] + 1
	i = i - 1
total = max(a)
if total < n:
	total = total + 1
for i in range(1, n - 1):
	if l[i - 1] + 1 < l[i + 1]:
		total = max(total, a[i - 1] + 1 + b[i + 1])
	else:
		total = max(total, a[i - 1] + 1)
print(total)


n = int(input())
a = list(map(int, input().split()))
ls = []
temp = [a[0]]
for i in range(1, n):
	if a[i] > a[i - 1]:
		temp.append(a[i])
	else:
		ls.append(temp)
		temp = [a[i]]
if len(temp):
	ls.append(temp)
ans = 0
for i in range(len(ls) - 1):
	ans = max(ans, len(ls[i]) + 1)
	if len(ls[i + 1]) > 1 and ls[i + 1][1] - ls[i][-1] > 1:
		ans = max(ans, len(ls[i]) + len(ls[i + 1]))
	if len(ls[i]) > 1 and ls[i + 1][0] - ls[i][-2] > 1:
		ans = max(ans, len(ls[i]) + len(ls[i + 1]))
ans = max(ans, len(ls[-1]) + 1)
print(min(ans, n))


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
	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)


n = int(input())
sequence = list(map(int, input().split()))
max_length = 0

def divide_sequences():
	global max_length
	result = []
	cur_sequence = []

	def add_sequence_to_result():
		global max_length
		result.append(cur_sequence)
		max_length = max(len(cur_sequence), max_length)
	last_elem = 0
	for k in range(len(sequence)):
		if sequence[k] > last_elem:
			cur_sequence.append(sequence[k])
		else:
			add_sequence_to_result()
			cur_sequence = list()
			cur_sequence.append(sequence[k])
		last_elem = sequence[k]
	if len(cur_sequence) > 0:
		add_sequence_to_result()
	return result
divided_sequences = divide_sequences()
if len(divided_sequences) > 1:
	max_length += 1

def can_merge(seq_one_index, seq_two_index):
	seq_one = divided_sequences[seq_one_index]
	seq_two = divided_sequences[seq_two_index]
	if len(seq_one) == 1 or len(seq_two) == 1:
		return True
	if seq_one[-2] + 1 < seq_two[0] or seq_one[-1] + 1 < seq_two[1]:
		return True
	return False
divided_sequences_length = len(divided_sequences)

def can_merge_three(seq_one_index, seq_two_index):
	seq_one = divided_sequences[seq_one_index]
	seq_two = divided_sequences[seq_two_index]
	return seq_two[0] - seq_one[-1] > 0
for k in range(1, divided_sequences_length):
	if can_merge(k - 1, k):
		max_length = max(max_length, len(divided_sequences[k]) + len(divided_sequences[k - 1]))
	if len(divided_sequences[k]) == 1 and k < divided_sequences_length - 1 and can_merge_three(k - 1, k + 1):
		max_length = max(max_length, len(divided_sequences[k + 1]) + len(divided_sequences[k - 1]) + 1)
print(max_length)


import sys
n = int(input())
a = list(map(int, input().split()))
a = [-1] + a + [10000007]
up = [0 for i in range(n + 2)]
down = [0 for i in range(n + 2)]
for i in range(1, n + 1):
	up[i] = up[i - 1] + 1 if a[i] > a[i - 1] else 1
for i in range(n, 0, -1):
	down[i] = down[i + 1] + 1 if a[i] < a[i + 1] else 1
maxi = 0
for i in range(1, n + 1):
	maxi = max(maxi, up[i - 1] + (a[i - 1] + 1 < a[i + 1]) * down[i + 1] + 1)
	maxi = max(maxi, up[i - 1] * (a[i - 1] + 1 < a[i + 1]) + down[i + 1] + 1)
print(maxi)


def solve(inp):
	n = len(inp)
	l = [0] * n
	r = [0] * n
	ans = 1
	l[0] = 1
	updateLeft(inp, l, n)
	updateRight(inp, r, n)
	for i in range(1, n - 1):
		if inp[i + 1] - inp[i - 1] >= 2:
			ans = max(ans, l[i - 1] + r[i + 1] + 1)
	for i in range(n - 1):
		ans = max(ans, r[i + 1] + 1)
	for i in range(1, n):
		ans = max(ans, l[i - 1] + 1)
	return ans

def updateRight(inp, r, n):
	p1 = n - 2
	p2 = n - 1
	r[n - 1] = 1
	while p1 >= 0:
		if inp[p1] >= inp[p1 + 1]:
			p2 = p1
		r[p1] = p2 - p1 + 1
		p1 -= 1

def updateLeft(inp, l, n):
	p1 = 0
	p2 = 1
	while p2 < n:
		if inp[p2] <= inp[p2 - 1]:
			p1 = p2
		l[p2] = p2 - p1 + 1
		p2 += 1
n = int(input())
lst = list(map(int, input().strip().split()))
print(solve(lst))


n = int(input())
a = list(map(int, input().split()))
l = [1] * n
r = [1] * n
for i in range(1, n):
	if a[i] > a[i - 1]:
		l[i] = l[i - 1] + 1
for i in range(n - 2, -1, -1):
	if a[i] < a[i + 1]:
		r[i] = r[i + 1] + 1
m = max(l)
if m < n:
	m = m + 1
for i in range(1, n - 1):
	if a[i - 1] + 1 < a[i + 1]:
		m = max(m, l[i - 1] + r[i + 1] + 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)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	if n <= 2:
		print(n)
		return
	left = [0 for _ in range(n)]
	right = [0 for _ in range(n)]
	left[0] = 1
	right[-1] = 1
	ans = 0
	for i in range(1, n):
		if a[i] > a[i - 1]:
			left[i] = left[i - 1] + 1
		else:
			left[i] = 1
		ans = max(ans, left[i - 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 = max(ans, right[i + 1] + 1)
	for i in range(1, n - 1):
		if a[i + 1] - a[i - 1] >= 2:
			ans = max(left[i - 1] + right[i + 1] + 1, ans)
	print(ans)
main()


num_nums = int(input())
nums = list(map(int, input().split(' ')))
increasing_subseqs = []
current_l = []
current_n = None
for i in range(len(nums)):
	if len(current_l) == 0:
		current_l.append(nums[i])
		current_n = nums[i]
	elif nums[i] > current_n:
		current_l.append(nums[i])
		current_n = nums[i]
	else:
		increasing_subseqs.append(current_l)
		current_l = [nums[i]]
		current_n = nums[i]
if len(current_l) > 0:
	increasing_subseqs.append(current_l)
longest = len(increasing_subseqs[0])
for i in range(len(increasing_subseqs) - 1):
	curr_ = increasing_subseqs[i]
	next_ = increasing_subseqs[i + 1]
	if len(curr_) > 1 and len(next_) > 1:
		if next_[1] > curr_[-1] + 1 or next_[0] > curr_[-2] + 1:
			longest = max(len(curr_) + len(next_), longest)
	longest = max(longest, len(curr_) + 1, len(next_) + 1)
print(longest)


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())
s = input()
s1 = s.split()
l = [int(i) for i in s1]
dp1 = [1 for i in range(len(l))]
for i in range(1, len(l)):
	if l[i] > l[i - 1]:
		dp1[i] = dp1[i - 1] + 1
dp2 = [1 for i in range(len(l))]
for i in range(len(l) - 2, -1, -1):
	if l[i] < l[i + 1]:
		dp2[i] = dp2[i + 1] + 1
maxlen = max(dp1)
for i in range(0, len(l)):
	if i + 1 < len(l) and i - 1 >= 0 and (l[i + 1] > l[i - 1] + 1):
		maxlen = max(dp1[i - 1] + dp2[i + 1] + 1, maxlen)
	if i - 1 >= 0 and l[i] <= l[i - 1]:
		maxlen = max(maxlen, dp1[i - 1] + 1)
	if i + 1 < len(l) and l[i] >= l[i + 1]:
		maxlen = max(maxlen, dp2[i + 1] + 1)
print(maxlen)


import sys

def inputArray():
	tp = str(input()).split()
	return list(map(int, tp))
n = int(input())
input = inputArray()
if n == 1:
	print('1')
	sys.exit()
left = [1 for x in range(n)]
right = [1 for x in range(n)]
for i in range(1, n, 1):
	if input[i - 1] < input[i]:
		left[i] = left[i - 1] + 1
for i in range(n - 2, -1, -1):
	if input[i] < input[i + 1]:
		right[i] = right[i + 1] + 1
ans = 1
for i in range(n):
	if i == 0:
		ans = max(ans, right[i + 1] + 1)
		continue
	if i == n - 1:
		ans = max(ans, left[i - 1] + 1)
		continue
	ans = max(ans, right[i + 1] + 1)
	ans = max(ans, left[i - 1] + 1)
	if input[i + 1] - input[i - 1] >= 2:
		ans = max(ans, left[i - 1] + 1 + right[i + 1])
print(ans)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	n = I()
	a = LI()
	if n < 3:
		return n
	b = [1]
	for i in range(1, n):
		if a[i - 1] < a[i]:
			b.append(b[-1] + 1)
		else:
			b.append(1)
	c = [1]
	for i in range(n - 2, -1, -1):
		if a[i + 1] > a[i]:
			c.append(c[-1] + 1)
		else:
			c.append(1)
	c = c[::-1]
	r = max(c[1], b[-2]) + 1
	for i in range(1, n - 1):
		if a[i + 1] - a[i - 1] > 1:
			t = b[i - 1] + c[i + 1] + 1
			if r < t:
				r = t
		else:
			t = max(b[i - 1], c[i + 1]) + 1
			if r < t:
				r = t
	return r
print(main())


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


n = int(input())
a = list(map(int, input().split()))
b = []
b.append(1)
for i in range(1, len(a)):
	if a[i] > a[i - 1]:
		b.append(b[i - 1] + 1)
	else:
		b.append(1)
for i in range(len(a) - 2, -1, -1):
	if a[i] < a[i + 1]:
		b[i] = b[i + 1]
ans = max(b) + 1
if len(a) > 2:
	for i in range(len(a) - 2):
		if a[i] >= a[i + 1]:
			if a[i + 2] - a[i] > 1 or a[i + 1] - a[i - 1] > 1:
				ans = max(ans, b[i] + b[i + 1])
print(min(ans, len(a)))


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))
(n,) = Neo()
A = Neo()
B = [1] * n
C = [1] * n
if n == 1:
	print(1)
	exit()
for i in range(1, n):
	if A[i] > A[i - 1]:
		B[i] += B[i - 1]
for i in range(n - 2, -1, -1):
	if A[i] < A[i + 1]:
		C[i] += C[i + 1]
Ans = max(B[-1], B[-2], C[0], C[1]) + 1
Ans = min(Ans, n)
for i in range(1, n - 1):
	if A[i] <= A[i - 1]:
		if A[i + 1] > A[i - 1] + 1:
			Ans = max(Ans, B[i - 1] + C[i + 1] + 1)
		else:
			Ans = max(Ans, B[i - 1] + 1)
	elif A[i] >= A[i + 1]:
		if A[i + 1] > A[i - 1] + 1:
			Ans = max(Ans, B[i - 1] + C[i + 1] + 1)
		else:
			Ans = max(Ans, C[i + 1] + 1)
print(Ans)


def fast_dzy_loves_sequence(a):
	a = [10 ** 9] + a + [0]
	lens = []
	left = []
	right = []
	c_left = 0
	c_right = 0
	for i in range(0, len(a)):
		if i > 0 and a[i - 1] < a[i]:
			c_left += 1
		else:
			c_left = 1
		left.append(c_left)
	for j in range(len(a) - 1, -1, -1):
		if j < len(a) - 1 and a[j + 1] > a[j]:
			c_right += 1
		else:
			c_right = 1
		right.append(c_right)
	right.reverse()
	left[0] = 0
	left[-1] = 0
	right[0] = 0
	right[-1] = 0
	for k in range(1, len(a) - 1):
		if a[k - 1] + 1 < a[k + 1]:
			this_len = left[k - 1] + 1 + right[k + 1]
		else:
			this_len = max(left[k - 1] + 1, right[k + 1] + 1)
		lens.append(this_len)
	return max(lens)
n = int(input())
a = [int(x) for x in input().split()]
print(fast_dzy_loves_sequence(a))


n = int(input())
if n == 1:
	print(1)
else:
	a = [int(i) for i in input().split()]
	good = [[0 for j in range(2)] for i in range(n)]
	good[0][1] = 1
	for i in range(n):
		if a[i] > a[i - 1]:
			good[i][1] = good[i - 1][1] + 1
		else:
			good[i][1] = 1
	good[n - 1][0] = 1
	for i in range(n - 2, -1, -1):
		if a[i] < a[i + 1]:
			good[i][0] = good[i + 1][0] + 1
		else:
			good[i][0] = 1
	mx = max(good[1][0] + 1, good[n - 2][1] + 1)
	for i in range(1, n - 1):
		if a[i + 1] - a[i - 1] > 1:
			mx = max(mx, good[i - 1][1] + good[i + 1][0] + 1)
		mx = max(mx, good[i - 1][1] + 1, good[i + 1][0] + 1)
	print(mx)


(n, b, i, ma) = (int(input()), [], 0, 0)
a = list(map(int, input().split()))
while i < n:
	j = i
	while j < n - 1 and a[j] < a[j + 1]:
		j += 1
	b.append([i, j])
	(ma, i) = (max(j - i + 1 + (i != 0 or j != n - 1), ma), j + 1)
for i in range(len(b) - 1):
	if b[i + 1][0] - b[i][1] == 2 and a[b[i + 1][0]] > a[b[i][1]] + 1:
		ma = max(ma, b[i + 1][1] - b[i][0] + 1)
	elif b[i + 1][0] - b[i][1] == 1:
		if b[i + 1][0] + 1 < n and a[b[i + 1][0] + 1] > a[b[i][1]] + 1 or (b[i][1] - 1 >= 0 and a[b[i][1] - 1] + 1 < a[b[i + 1][0]]):
			ma = max(ma, b[i + 1][1] - b[i][0] + 1)
print(ma)


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


a = int(input())
z = list(map(int, input().split()))
dp = [[0 for i in range(len(z))] for i in range(2)]
ans = [1]
for i in range(1, len(z)):
	if z[i] > z[i - 1]:
		ans.append(ans[-1] + 1)
	else:
		ans.append(1)
dp[0][0] = 1
dp[1][0] = 0
maxa = 1
for i in range(1, len(z)):
	if z[i] > z[i - 1]:
		if i == 1:
			dp[0][i] = 2
			dp[1][i] = 2
			maxa = max(dp[0][i], dp[1][i], maxa)
			continue
		dp[1][i] = ans[i - 1] + 1
		dp[0][i] = dp[0][i - 1] + 1
		if z[i - 2] + 1 < z[i]:
			dp[0][i] = max(dp[1][i - 1] + 1, dp[0][i])
		maxa = max(maxa, dp[0][i], dp[1][i])
	else:
		if i == 1:
			dp[0][i] = 2
			dp[1][i] = 2
			maxa = max(dp[0][i], dp[1][i], maxa)
			continue
		dp[1][i] = ans[i - 1] + 1
		dp[0][i] = 2
		if z[i - 2] + 1 < z[i]:
			dp[0][i] = max(dp[1][i - 1] + 1, dp[0][i])
		maxa = max(dp[0][i], dp[1][i], maxa)
print(maxa)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from math import sqrt, pi, ceil, log, inf, gcd, floor
from itertools import combinations, permutations
from bisect import *
from fractions import Fraction
from heapq import *
from random import randint

def main():
	n = int(input())
	a = list(map(int, input().split()))
	(b, i) = ([], 0)
	while i < n:
		j = i
		while j < n - 1 and a[j] < a[j + 1]:
			j += 1
		b.append([i, j])
		i = j + 1
	ma = 0
	for i in range(len(b) - 1):
		if b[i + 1][0] - b[i][1] == 2 and a[b[i + 1][0]] > a[b[i][1]] + 1:
			ma = max(ma, b[i + 1][1] - b[i][0] + 1)
		elif b[i + 1][0] - b[i][1] == 1:
			ma = max(ma, b[i + 1][0] - b[i][0] + 1)
			if b[i + 1][0] + 1 < n and a[b[i + 1][0] + 1] > a[b[i][1]] + 1 or (b[i][1] - 1 >= 0 and a[b[i][1] - 1] + 1 < a[b[i + 1][0]]):
				ma = max(ma, b[i + 1][1] - b[i][0] + 1)
			ma = max(ma, b[i + 1][1] - b[i + 1][0] + 2)
		ma = max(ma, b[i][1] - b[i][0] + 1)
	ma = max(ma, b[-1][1] - b[-1][0] + 1)
	print(ma)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
s = list(map(int, input().split()))
B = [1]
E = [1]
ans = 0
if n < 3:
	print(n)
else:
	for i in range(1, n):
		if s[i] > s[i - 1]:
			B.append(B[-1] + 1)
		else:
			B.append(1)
	for i in range(n - 1, 0, -1):
		if s[i] > s[i - 1]:
			E.append(E[-1] + 1)
		else:
			E.append(1)
	for i in range(-1, n - 1):
		if i == n - 2:
			ans = max(ans, B[i] + 1)
		elif i == -1:
			ans = max(ans, E[n - 2] + 1)
		elif s[i + 2] - s[i] > 1:
			ans = max(ans, B[i] + E[n - i - 3] + 1)
		else:
			ans = max(ans, B[i] + 1, E[n - i - 3] + 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()


n = int(input())
A = input()
A = A.split()
i = 0
while i < n:
	A[i] = int(A[i])
	i = i + 1
opt_solutions_0 = list()
opt_solutions_1 = list()
i = 0
while i < n:
	opt_solutions_0.append(0)
	opt_solutions_1.append(0)
	i = i + 1
opt_solutions_0[0] = 1
opt_solutions_1[0] = 1
i = 1
while i < n:
	if A[i] > A[i - 1]:
		opt_solutions_0[i] = opt_solutions_0[i - 1] + 1
	else:
		opt_solutions_0[i] = 1
	if i >= 3:
		if A[i - 1] < A[i]:
			if A[i - 2] < A[i - 1]:
				opt_solutions_1[i] = opt_solutions_1[i - 1] + 1
			elif A[i - 2] >= A[i - 1]:
				case1_1 = None
				if A[i] - A[i - 2] >= 2:
					case1_1 = opt_solutions_0[i - 2] + 2
				else:
					case1_1 = 2
				case1_2 = None
				if A[i - 1] - A[i - 3] >= 2:
					case1_2 = opt_solutions_0[i - 3] + 3
				else:
					case1_2 = 3
				if case1_1 >= case1_2:
					opt_solutions_1[i] = case1_1
				else:
					opt_solutions_1[i] = case1_2
		elif A[i] - A[i - 2] >= 2:
			opt_solutions_1[i] = opt_solutions_0[i - 2] + 2
		else:
			opt_solutions_1[i] = opt_solutions_0[i - 1] + 1
	elif i == 2:
		if A[i - 1] < A[i]:
			opt_solutions_1[i] = 3
		elif A[i] - A[i - 2] >= 2:
			opt_solutions_1[i] = opt_solutions_0[i - 2] + 2
		else:
			opt_solutions_1[i] = opt_solutions_0[i - 1] + 1
	else:
		opt_solutions_1[i] = 2
	i = i + 1
max_l = opt_solutions_1[0]
i = 1
while i < n:
	if opt_solutions_1[i] > max_l:
		max_l = opt_solutions_1[i]
	i = i + 1
print(max_l)


import sys

def solve(n, a):
	t = [0] * (n + 1)
	a = [0] + a
	for i in range(1, n + 1):
		if a[i] > a[i - 1]:
			t[i] = t[i - 1] + 1
		else:
			t[i] = 1
	r = 0
	for i in range(1, n + 1):
		r = max(r, t[i])
		cur_max = t[i]
		if a[i - cur_max] >= a[i - cur_max + 1] and a[i - cur_max - 1] < a[i - cur_max + 1] - 1:
			new_max = t[i - cur_max - 1] + 1 + t[i]
			r = max(r, new_max)
		elif i - cur_max + 2 <= i and a[i - cur_max] < a[i - cur_max + 2] - 1:
			new_max = t[i] + t[i - cur_max]
			r = max(r, new_max)
	return max(r, min(n, max(t) + 1))
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().strip().split()))
r = solve(n, a)
print(r)


import random
n = int(input())
a = list(map(int, input().split()))
inc = []
j = 0
for i in range(len(a)):
	if i != len(a) - 1 and a[i] < a[i + 1]:
		if j == 0:
			first = a[i]
		if j == 1:
			second = a[i]
		j += 1
	else:
		if j == 1:
			second = a[i]
		if j == 0:
			inc.append((a[i], a[i], a[i], a[i], j + 1))
		else:
			inc.append((first, second, a[i - 1], a[i], j + 1))
		j = 0
if len(inc) == 1:
	print(inc[0][4])
	exit()
inc2 = []
for i in range(len(inc) - 1):
	if inc[i][3] + 1 < inc[i + 1][1]:
		inc2.append(inc[i][4] + inc[i + 1][4])
	if inc[i][2] + 1 < inc[i + 1][0]:
		inc2.append(inc[i][4] + inc[i + 1][4])
	inc2.append(max(inc[i][4] + 1, inc[i + 1][4] + 1))
print(max(inc2))


n = int(input())
nums = list(map(int, str(input()).split(' ')))
increasing_subs = []
l = 0
r = 0
for i in range(n):
	if i == 0:
		continue
	if nums[i - 1] < nums[i]:
		r += 1
	else:
		increasing_subs.append((l, r))
		l = i
		r = i
	if i == n - 1:
		increasing_subs.append((l, r))
if n > 1:
	maxi = max([x[1] - x[0] + 1 for x in increasing_subs]) + (len(increasing_subs) != 1)
else:
	maxi = 1
for i in range(len(increasing_subs)):
	if i != 0:
		a = increasing_subs[i - 1]
		b = increasing_subs[i]
		if a[0] != a[1] and b[0] != b[1] and (nums[b[0] + 1] - nums[a[1]] > 1 or nums[b[0]] - nums[a[1] - 1] > 1):
			maxi = max(maxi, b[1] - a[0] + 1)
		elif b[0] == b[1]:
			maxi = max(maxi, a[1] + 1 - a[0] + 1)
		elif a[0] == a[1]:
			maxi = max(maxi, b[1] - (b[0] + 1) + 1)
print(maxi)


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():
	(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()


from sys import *
from math import *
from collections import *
n = int(stdin.readline())
l = list(map(int, stdin.readline().split()))
end = [1] * (n + 1)
start = [1] * (n + 1)
for i in range(1, n):
	if l[i] > l[i - 1]:
		end[i] += end[i - 1]
for i in range(n - 2, -1, -1):
	if l[i] < l[i + 1]:
		start[i] += start[i + 1]
ans = max(end)
if ans < n:
	ans += 1
for i in range(1, n - 1):
	if l[i - 1] + 1 < l[i + 1]:
		ans = max(ans, end[i - 1] + start[i + 1] + 1)
print(ans)


import sys, math
input = sys.stdin.readline

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input().strip()

def listStr():
	return list(input().strip())
import collections as col
import math

def solve():
	N = getInt()
	A = getInts()
	if N == 1:
		return 1
	subsequences = []
	ind = 0
	(ind, curr_len) = (0, 0)
	while ind < N:
		if ind == 0:
			curr_len += 1
			ind += 1
			continue
		if A[ind] <= A[ind - 1]:
			for j in range(curr_len):
				subsequences.append(curr_len - j)
			curr_len = 1
		else:
			curr_len += 1
		if ind == N - 1:
			for j in range(curr_len):
				subsequences.append(curr_len - j)
		ind += 1
	best = 0
	for j in range(N):
		start_len = subsequences[j]
		best = max(best, start_len)
		if start_len + j < N or j > 0:
			best = max(best, start_len + 1)
		if start_len + j + 1 < N and A[start_len + j + 1] - A[start_len + j - 1] > 1:
			best = max(best, start_len + 1 + subsequences[start_len + j + 1])
		if start_len + j < N and start_len + j - 2 >= 0 and (A[start_len + j] - A[start_len + j - 2] > 1):
			best = max(best, start_len + subsequences[start_len + j])
	return best
print(solve())


arg = int(input())
list1 = list(map(int, input().strip().split()))
origarr = [a for a in list1]
res = 1
if arg == 1:
	print(1)
else:
	global_maximum = 0
	if list1[1] <= list1[0]:
		orig_i = 0
		orig = list1[0]
		list1[0] = list1[1] - 1
		counter = 1
		maximum = 2
		current = list1[1]
		index = 2
	else:
		maximum = 1
		counter = 0
		current = list1[0]
		index = 1
	while True:
		if index == arg:
			global_maximum = max(global_maximum, res, maximum)
			break
		if list1[index] > current:
			maximum += 1
		elif counter == 0:
			orig_i = index
			orig = list1[index]
			list1[index] = current + 1
			counter += 1
			maximum += 1
		else:
			counter = 0
			if maximum > res:
				res = maximum
			maximum = 1
			list1[orig_i] = orig
			index = orig_i
		current = list1[index]
		index += 1
	list1 = [a for a in origarr]
	list1.reverse()
	res = 1
	if list1[1] >= list1[0]:
		orig_i = 0
		orig = list1[0]
		list1[0] = list1[1] + 1
		counter = 1
		maximum = 2
		current = list1[1]
		index = 2
	else:
		maximum = 1
		counter = 0
		current = list1[0]
		index = 1
	while True:
		if index == arg:
			global_maximum = max(global_maximum, res, maximum)
			break
		if list1[index] < current:
			maximum += 1
		elif counter == 0:
			orig_i = index
			orig = list1[index]
			list1[index] = current - 1
			counter += 1
			maximum += 1
		else:
			counter = 0
			if maximum > res:
				res = maximum
			maximum = 1
			list1[orig_i] = orig
			index = orig_i
		current = list1[index]
		index += 1
	print(global_maximum)


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, input().split()))
for i in range(1):
	n = nmbr()
	a = lst()
	if n == 1:
		print(1)
		continue
	f = [1] * n
	b = [1] * (1 + n)
	for i in range(1, n):
		if a[i] > a[i - 1]:
			f[i] = 1 + f[i - 1]
	for i in range(n - 2, -1, -1):
		if a[i] < a[i + 1]:
			b[i] = b[i + 1] + 1
	ans = min(n, max(f) + 1)
	for i in range(n):
		if i - 1 >= 0 and i + 1 < n and (a[i - 1] + 2 <= a[i + 1]):
			ans = max(ans, f[i - 1] + b[i + 1] + 1)
	print(ans)


n = int(input())
a = list(map(int, input().split()))
pre = [1 for i in range(n)]
suf = [1 for i in range(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, -1, -1):
	if a[i] < a[i + 1]:
		suf[i] = suf[i + 1] + 1
ans = 0
for i in range(n):
	if i == 0:
		ans = max(ans, min(n, suf[i] + 1))
	elif i == n - 1:
		ans = max(ans, min(n, pre[i] + 1))
	else:
		ans = max(ans, min(n, 1 + pre[i]), min(1 + suf[i], n))
		if a[i - 1] + 1 < a[i + 1]:
			ans = max(ans, pre[i - 1] + 1 + suf[i + 1])
if n == 1:
	ans = 1
print(ans)


n = int(input())
l = [*map(int, input().split())]
res = [[0, 0]]
for i in range(1, n):
	if l[i] <= l[res[-1][-1]]:
		res.append([i, i])
	else:
		res[-1][-1] = i
f = lambda p: p[-1] - p[0] + 1
ans = f(res[0])
for (i, p) in enumerate(res):
	if i < len(res) - 1:
		v = f(p)
		if f(res[i + 1]) > 1 and l[p[-1]] + 1 < l[res[i + 1][0] + 1]:
			v += f(res[i + 1])
		else:
			v += 1
		ans = max(ans, v)
	if i > 0:
		v = f(p)
		if f(res[i - 1]) > 1 and l[res[i - 1][1] - 1] + 1 < l[p[0]]:
			v += f(res[i - 1])
		else:
			v += 1
		ans = max(ans, v)
print(ans)


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()))
b = [1]
for i in range(1, n):
	if a[i] > a[i - 1]:
		b.append(b[-1] + 1)
	else:
		b.append(1)
ans = max(b)
if ans != n:
	ans += 1
c = [0] * n
i = n - 1
val = b[-1]
while i >= 0:
	for j in range(val):
		c[i] = val
		i -= 1
	val = b[i]
for i in range(1, n - 1):
	if a[i + 1] - a[i - 1] >= 2:
		if b[i] == 1:
			ans = max(ans, c[i - 1] + c[i])
		elif b[i + 1] == 1:
			ans = max(ans, c[i + 1] + c[i])
print(ans)


import sys
input = sys.stdin.buffer.readline

def solution():
	n = int(input())
	l = list(map(int, input().split()))
	end = [1] * (n + 1)
	start = [1] * (n + 1)
	for i in range(1, n):
		if l[i] > l[i - 1]:
			end[i] += end[i - 1]
	for i in range(n - 2, -1, -1):
		if l[i] < l[i + 1]:
			start[i] += start[i + 1]
	ans = max(end)
	if ans < n:
		ans += 1
	for i in range(1, n - 1):
		if l[i - 1] + 1 < l[i + 1]:
			ans = max(ans, end[i - 1] + start[i + 1] + 1)
	print(ans)
solution()


from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def solve():
	n = ii()
	a = li()
	pre = [1] * n
	suf = [1] * n
	ans = 2
	for i in range(1, n):
		if a[i] > a[i - 1]:
			pre[i] = pre[i - 1] + 1
		ans = max(ans, pre[i])
	for i in range(n - 2, -1, -1):
		if a[i] < a[i + 1]:
			suf[i] = suf[i + 1] + 1
		ans = max(ans, pre[i])
	for i in range(1, n - 1):
		x = a[i + 1] - a[i - 1]
		if x > 1:
			ans = max(ans, 1 + pre[i - 1] + suf[i + 1])
		ans = max(ans, 1 + pre[i])
		ans = max(ans, 1 + suf[i])
	print(min(ans, n))
solve()


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


n = int(input())
a = list(map(int, input().split()))
ans = 0
cnt = 1
q = []
for i in range(n - 1):
	if a[i] < a[i + 1]:
		cnt += 1
	else:
		q.append([cnt, i])
		cnt = 1
q.append([cnt, n - 1])
for i in range(len(q) - 1):
	(c1, idx1) = q[i]
	(c2, idx2) = q[i + 1]
	if idx1 + 2 < n and a[idx1] + 1 < a[idx1 + 2]:
		ans = max(ans, c1 + c2)
	elif 0 <= idx1 - 1 and idx1 + 1 < n and (a[idx1 - 1] + 1 < a[idx1 + 1]):
		ans = max(ans, c1 + c2)
	else:
		ans = max(ans, c1)
ans = max(ans, q[-1][0])
for i in range(len(q)):
	(c1, idx1) = q[i]
	if idx1 + 1 < n:
		ans = max(ans, c1 + 1)
for i in range(1, len(q)):
	(c1, idx1) = q[i]
	if idx1 - 1 >= 0:
		ans = max(ans, c1 + 1)
print(ans)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
INF = 999999999999999999999999

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		n = ri()
		a = ria() + [-INF]
		seq = []
		currseq = [a[0]]
		for i in range(len(a) - 1):
			if a[i] < a[i + 1]:
				currseq.append(a[i + 1])
			else:
				seq.append(currseq)
				currseq = [a[i + 1]]
		if len(seq) == 1:
			print(n)
		else:
			ans = 0
			for i in range(len(seq) - 1):
				(x, y) = (seq[i], seq[i + 1])
				ans = max(ans, len(x) + 1, len(y) + 1)
				if min(len(x), len(y)) > 1 and (y[0] - x[-2] > 1 or y[1] - x[-1] > 1):
					ans = max(ans, len(x) + len(y))
			print(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


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)
		elif 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)


n = int(input())
l = list(map(int, input().split())) + [-99 ** 9]
t = 1
p = []
for i in range(1, n + 1):
	if l[i] > l[i - 1]:
		t += 1
	else:
		p.append((t, i - 1))
		t = 1
best = p[0][0]
for i in range(len(p) - 1):
	uz = p[i][0]
	end = p[i][1]
	uz2 = p[i + 1][0]
	end2 = p[i + 1][1]
	if uz == 1 or uz2 == 1:
		best = max(best, uz2 + 1, uz + 1)
	else:
		k1 = end
		k2 = end2 - uz2 + 1
		el1 = l[k2] - 1
		el2 = l[k1] + 1
		if el1 > l[k1 - 1] or el2 < l[k2 + 1]:
			best = max(best, uz2 + uz, uz2 + 1, uz + 1)
		else:
			best = max(best, uz2 + 1, uz + 1)
print(best)


from sys import stdin
input = stdin.readline
n = int(input())
a = [-100] + [*map(int, input().split())] + [10 ** 9 + 100]
c = 0
ans = []
for (i, j) in enumerate(a):
	if 1 <= i <= n:
		if a[i - 1] < a[i]:
			c += 1
		else:
			ans.append(c)
			c = 1
			if a[i + 1] - a[i - 1] > 1 or a[i] - a[i - 2] > 1:
				ans.append(True)
			else:
				ans.append(False)
	if i == n + 1:
		ans.append(c)
k = 0
for (i, j) in enumerate(ans):
	if type(j) == bool:
		if j:
			k = max(k, ans[i - 1] + ans[i + 1])
		else:
			k = max(k, ans[i - 1] + 1, ans[i + 1] + 1)
	else:
		k = max(k, j)
print(k)


import sys
import math
num = int(sys.stdin.readline())
numArr = [int(x) for x in sys.stdin.readline().split()]
startIndex = 0
endIndex = 1
maxLength = 0
currentLength = 0
changeIndex = 0
while endIndex < len(numArr):
	currentNum = numArr[endIndex - 1]
	originalChange = changeIndex
	currentLength = endIndex - changeIndex
	while endIndex < len(numArr) and numArr[endIndex] > currentNum:
		currentLength += 1
		currentNum = numArr[endIndex]
		endIndex += 1
	backSum = 0
	if changeIndex != 0:
		backSum = 1
		backIndex = changeIndex - 1
		if backIndex > 0:
			backNum = numArr[changeIndex] - 1
			backIndex -= 1
			while backIndex >= 0 and numArr[backIndex] < backNum:
				backSum += 1
				backNum = numArr[backIndex]
				backIndex -= 1
	forwardSum = 0
	if endIndex != len(numArr):
		changeIndex = endIndex
		endIndex += 1
		forwardSum += 1
		tempNum = currentNum + 1
	while endIndex < len(numArr) and numArr[endIndex] > tempNum:
		tempNum = numArr[endIndex]
		endIndex += 1
		forwardSum += 1
	currentLength += max(backSum, forwardSum)
	if currentLength > maxLength:
		maxLength = currentLength
if len(numArr) == 1:
	print(1)
elif maxLength > num:
	print(num)
else:
	print(maxLength)


n = int(input())
a = list(map(int, input().strip().split()))
inc = [0 for i in range(n)]
inc[0] = 1
for i in range(1, n):
	if a[i] > a[i - 1]:
		inc[i] = inc[i - 1] + 1
	else:
		inc[i] = inc[0]
dec = [0 for i in range(n)]
dec[-1] = 1
for i in range(n - 2, -1, -1):
	if a[i] < a[i + 1]:
		dec[i] = dec[i + 1] + 1
	else:
		dec[i] = dec[-1]
maxi = 1
for i in range(1, n - 1):
	if a[i - 1] - a[i + 1] < -1:
		maxi = max(maxi, inc[i - 1] + dec[i + 1] + 1)
	maxi = max(maxi, inc[i] + 1, dec[i] + 1)
if n == 2:
	print(2)
else:
	print(maxi)


n = int(input())
if n <= 2:
	print(n)
	exit()
a = list(map(int, input().split()))
lower = [0 for _ in range(n)]
higher = [0 for _ in range(n)]
current = 0
e = -1
for x in range(n):
	if a[x] > e:
		current += 1
	else:
		for y in range(current):
			lower[x - 1 - y] = y + 1
			higher[x - 1 - y] = current - y
		current = 1
	e = a[x]
x = n
for y in range(current):
	lower[x - 1 - y] = y + 1
	higher[x - 1 - y] = current - y
best = max(lower)
x = 1
while x < n - 1:
	inc = a[x - 1] + 1
	dec = a[x + 1] - 1
	seq = 1
	best = max(best, seq + higher[x - 1])
	best = max(best, seq + lower[x + 1])
	if inc < a[x + 1] or dec > a[x - 1]:
		best = max(best, seq + higher[x - 1] + lower[x + 1])
	x += 1
if a[-1] <= a[-2]:
	best = max(best, higher[-2] + 1)
if a[0] >= a[1]:
	best = max(best, lower[1] + 1)
print(best)


from bisect import bisect_left
n = int(input())
l = [int(i) for i in input().split()]
(left, right) = ([1] * n, [1] * n)
for i in range(1, n):
	if l[i] > l[i - 1]:
		left[i] = left[i - 1] + 1
for i in range(n - 2, -1, -1):
	if l[i] < l[i + 1]:
		right[i] = right[i + 1] + 1
ans = min(max(left) + 1, n)
for i in range(n - 2):
	if l[i + 2] - l[i] >= 2:
		ans = max(ans, left[i] + right[i + 2] + 1)
print(ans)


(dp_right, dp_left) = ([], [])

def solve(n, a):
	a.insert(0, 0)
	a.append(0)
	for i in range(1000005):
		dp_right.append(0)
		dp_left.append(0)
	res = 0
	for i in range(1, n + 1):
		if a[i] > a[i - 1]:
			dp_right[i] = dp_right[i - 1] + 1
		else:
			dp_right[i] = 1
		res = max(res, dp_right[i])
	for i in range(n, 1 - 1, -1):
		if a[i] < a[i + 1]:
			dp_left[i] = dp_left[i + 1] + 1
		else:
			dp_left[i] = 1
	for i in range(1, n + 1):
		res = max(res, max(dp_right[i - 1] + 1, dp_left[i + 1] + 1))
		if a[i - 1] + 1 < a[i + 1]:
			res = max(res, dp_right[i - 1] + 1 + dp_left[i + 1])
	return res

def dp010_dzy_loves_sequences(n, a):
	return solve(n, a)
n = int(input())
a = list(map(int, input().split()))
print(dp010_dzy_loves_sequences(n, a))


n = int(input())
l = list(map(int, input().split()))
(i, j) = (0, 0)
used_flip = False
max_length = 1
prev_value = l[0]
while i < n:
	if i - 1 >= 0 and l[i - 1] >= l[i]:
		used_flip = False
		prev_value = l[j]
	elif i + 1 < n and l[i + 1] <= l[i]:
		used_flip = True
		(j, prev_value) = (i + 1, l[i + 1])
		max_length = max(max_length, 2)
	while j + 1 < n:
		if l[j + 1] > prev_value:
			prev_value = l[j + 1]
			j = j + 1
		elif not used_flip:
			if i == j or l[j + 1] - l[j - 1] >= 2:
				prev_value = l[j + 1]
				(j, used_flip) = (j + 1, True)
			else:
				prev_value = l[j] + 1
				(j, used_flip) = (j + 1, True)
		else:
			break
		max_length = max(max_length, j - i + 1)
	i += 1
print(max_length)


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:
			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())
nums = list(map(int, input().split()))
l = [1] * n
r = [1] * n
for i in range(1, n):
	if nums[i] > nums[i - 1]:
		l[i] = l[i - 1] + 1
for i in range(n - 2, -1, -1):
	if nums[i] < nums[i + 1]:
		r[i] = r[i + 1] + 1
ans = max(l)
if ans < n:
	ans += 1
for i in range(1, n - 1):
	if nums[i - 1] + 1 < nums[i + 1]:
		ans = max(ans, l[i - 1] + r[i + 1] + 1)
print(ans)
print('\n')


def find_longest_streak(n, nums):
	if n < 2:
		return n
	rights = [0] * n
	lefts = [0] * n
	rights[0] = 1
	lefts[n - 1] = 1
	for i in range(1, n):
		if nums[i] > nums[i - 1]:
			rights[i] = rights[i - 1] + 1
		else:
			rights[i] = 1
	for i in range(n - 2, -1, -1):
		if nums[i] < nums[i + 1]:
			lefts[i] = lefts[i + 1] + 1
		else:
			lefts[i] = 1
	highest = 0
	for i in range(n):
		highest = max(highest, change_value(n, nums, i, rights, lefts))
	return highest

def change_value(n, nums, index, rights, lefts):
	if index - 1 < 0:
		return lefts[index + 1] + 1
	if index + 1 == n:
		return rights[index - 1] + 1
	if nums[index - 1] < nums[index + 1] - 1:
		return 1 + rights[index - 1] + lefts[index + 1]
	else:
		return max(rights[index - 1], lefts[index + 1]) + 1
n = int(input())
nums = [int(i) for i in input().split(' ')]
print(find_longest_streak(n, nums))


R = lambda : map(int, input().split())
n = int(input())
a = list(R())
dp = [1] * n
res = min(2, n)
for i in range(n - 2, -1, -1):
	dp[i] = dp[i + 1] + 1 if a[i] < a[i + 1] else 1
cnt = 0
for i in range(n):
	if 0 < i < n - 1 and a[i + 1] > a[i - 1] + 1:
		res = max(res, cnt + dp[i + 1] + 1)
	else:
		res = max(res, cnt + 1, dp[i + 1] + 1 if i < n - 1 else 1)
	cnt = cnt + 1 if i > 0 and a[i] > a[i - 1] else 1
print(res)


n = int(input())
arr = [int(x) for x in input().split(' ')]
af = [0] * n
ab = [0] * n
for i in range(n):
	if i == 0 or arr[i] <= arr[i - 1]:
		af[i] = 1
	else:
		af[i] = af[i - 1] + 1
for i in range(n - 1, -1, -1):
	if i == n - 1 or arr[i] >= arr[i + 1]:
		ab[i] = 1
	else:
		ab[i] = ab[i + 1] + 1
ans = 0
for i in range(n):
	if i == 0:
		left = 0
	else:
		left = af[i - 1]
	if i == n - 1:
		right = 0
	else:
		right = ab[i + 1]
	if left and right and (arr[i - 1] + 2 <= arr[i + 1]):
		ans = max(ans, left + right + 1)
	else:
		ans = max(ans, max(left, right) + 1)
print(ans)


sequenceLength = int(input())
sequence = list(map(int, input().split()))
ans = 0
leftList = [1] * sequenceLength
rightlist = [1] * sequenceLength
for i in range(1, sequenceLength):
	if sequence[i - 1] < sequence[i]:
		leftList[i] += leftList[i - 1]
	ans = max(ans, leftList[i])
if ans < sequenceLength:
	ans += 1
for i in range(sequenceLength - 2, 0, -1):
	if sequence[i + 1] > sequence[i]:
		rightlist[i] += rightlist[i + 1]
for i in range(1, sequenceLength - 1):
	if sequence[i + 1] - sequence[i - 1] >= 2:
		ans = max(ans, leftList[i - 1] + 1 + rightlist[i + 1])
print(ans)


n = int(input())
c = [0] * (n + 2)
d = [1] * (n + 2)
a = [1] * (n + 2)
a[0] = 0
d[-1] = 0
for (i, x) in enumerate(map(int, input().split()), 1):
	c[i] = x
	if c[i] > c[i - 1]:
		a[i] = a[i - 1] + 1
for i in range(n, 0, -1):
	if c[i] < c[i + 1]:
		d[i] = d[i + 1] + 1
m = 0
for i in range(1, n + 1):
	if c[i + 1] - c[i - 1] > 1:
		m = max(m, a[i - 1] + d[i + 1] + 1)
	else:
		m = max(m, a[i - 1] + 1, d[i + 1] + 1)
print(m)


n = int(input())
arr = list(map(int, input().split()))
l = [1 for i in range(n)]
m = [1 for i in range(n)]
f = 1
for i in range(n):
	if i != n - 1:
		if arr[i + 1] > arr[i]:
			l[i + 1] += l[i]
for i in range(n - 2, -1, -1):
	if arr[i + 1] > arr[i]:
		m[i] += m[i + 1]
max1 = max(l)
z = max1
for i in range(n - 2):
	if arr[i + 2] - arr[i] > 1:
		max1 = max(max1, l[i] + m[i + 2] + 1)
if z == max1 and max1 != n:
	max1 += 1
print(max1)


n = int(input())
alist = [int(x) for x in input().split()]
maximum = 2
l = [1] * n
r = l[:]
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)


n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print(1)
else:
	right = [1] * n
	left = [1] * n
	for i in range(1, n):
		if a[i] > a[i - 1]:
			right[i] = right[i - 1] + 1
	for i in range(n - 2, -1, -1):
		if a[i] < a[i + 1]:
			left[i] = left[i + 1] + 1
	mx = max(max(right), max(left))
	for i in range(n):
		if i == 0:
			if a[i] >= a[i + 1]:
				mx = max(mx, left[i + 1] + 1)
			else:
				mx = max(mx, left[i])
		elif i == n - 1:
			if a[i] <= a[i - 1]:
				mx = max(mx, right[i - 1] + 1)
			else:
				mx = max(mx, right[i])
		elif not a[i - 1] < a[i] < a[i + 1]:
			if a[i - 1] < a[i + 1] - 1:
				mx = max(mx, left[i + 1] + right[i - 1] + 1)
			else:
				mx = max(mx, right[i - 1] + 1, left[i + 1] + 1)
	print(mx)


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)


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


from sys import stdin
n = int(input())
s = list(map(int, stdin.readline().strip().split()))
dp = [1 for i in range(n)]
x = 1
for i in range(n - 2, -1, -1):
	if s[i] < s[i + 1]:
		x += 1
	else:
		x = 1
	dp[i] = x
ans = 1
for i in range(n):
	ans = max(ans, min(n, dp[i] + 1))
	aux = i + dp[i]
	if aux + 1 < n and abs(s[aux - 1] - s[aux + 1]) > 1 and (s[aux - 1] < s[aux + 1]):
		ans = max(ans, dp[i] + 1 + dp[aux + 1])
	aux -= 1
	if aux > 0 and aux + 1 < n and (abs(s[aux - 1] - s[aux + 1]) > 1) and (s[aux - 1] < s[aux + 1]):
		ans = max(ans, dp[i] + dp[aux + 1])
print(ans)


import sys
import math
from pprint import pprint
n = int(input())
a = [0] + list(map(int, input().split())) + [0]
l = [0 for i in range(n + 3)]
r = [0 for i in range(n + 3)]
ans = 1
for i in range(1, n + 1):
	if a[i] > a[i - 1]:
		l[i] = l[i - 1] + 1
	else:
		l[i] = 1
	ans = max(ans, l[i - 1] + 1)
for i in range(n, 0, -1):
	if a[i] < a[i + 1]:
		r[i] = r[i + 1] + 1
	else:
		r[i] = 1
	ans = max(ans, r[i + 1] + 1)
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])
print(ans)


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)


import math
from math import log2, sqrt
import sys
sys.setrecursionlimit(pow(10, 6))
import collections
from collections import defaultdict
from statistics import median
inf = float('inf')
mod = pow(10, 9) + 7

def gen_left(a):
	l = [0] * n
	for i in range(1, len(l)):
		if a[i] > a[i - 1]:
			l[i] = l[i - 1] + 1
	return l

def gen_right(a):
	r = [0] * n
	for i in reversed(range(len(l) - 1)):
		if a[i] < a[i + 1]:
			r[i] = r[i + 1] + 1
	return r

def generate(a, l, r):
	ans = 0
	for i in range(n):
		if i == 0:
			ans = max(ans, r[i + 1] + 1 + 1)
		elif i == n - 1:
			ans = max(ans, l[n - 2] + 1 + 1)
		elif a[i - 1] + 1 < a[i + 1]:
			ans = max(ans, r[i + 1] + 1 + l[i - 1] + 1 + 1)
		else:
			ans = max(ans, r[i + 1] + 1 + 1, l[i - 1] + 1 + 1)
	return ans
t = 1
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(1)
		continue
	if n == 2:
		print(2)
		continue
	l = gen_left(a)
	r = gen_right(a)
	ans = generate(a, l, r)
	print(ans)


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


N = eval(input())
Data = [10 ** 9 + 5] + list(map(int, input().split())) + [0]
(l, r, ans) = ([0] + [1] * N + [0], [0] + [1] * N + [0], 1)
for i in range(1, N + 2):
	if Data[i - 1] < Data[i]:
		l[i] += l[i - 1]
for i in range(N, 0, -1):
	if Data[i] < Data[i + 1]:
		r[i] += r[i + 1]
for i in range(1, N + 1):
	if Data[i - 1] + 1 < Data[i + 1]:
		ans = max(ans, l[i - 1] + 1 + r[i + 1])
	else:
		ans = max(ans, max(l[i - 1] + 1, 1 + r[i + 1]))
print(ans)


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


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]))


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
print(solve())


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

def next_str():
	global 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)


def seq(arr):
	l = [1] * len(arr)
	r = [1] * len(arr)
	for i in range(1, len(arr)):
		if arr[i] > arr[i - 1]:
			l[i] = l[i - 1] + 1
	for i in range(len(arr) - 2, -1, -1):
		if arr[i] < arr[i + 1]:
			r[i] = r[i + 1] + 1
	m = max(l)
	if m < len(arr):
		m += 1
	for i in range(1, len(arr) - 1):
		if arr[i - 1] + 1 < arr[i + 1]:
			m = max(m, l[i - 1] + r[i + 1] + 1)
	return m
a = input()
lst = list(map(int, input().strip().split()))
print(seq(lst))


import os
from sys import stdin, stdout

def solve(tc):
	n = int(stdin.readline().strip())
	seq = list(map(int, stdin.readline().split()))
	if n == 1:
		print(1)
		return
	rhs = [0 for i in range(n)]
	for i in range(n):
		if i == 0 or seq[i] <= seq[i - 1]:
			rhs[i] = 1
		else:
			rhs[i] = rhs[i - 1] + 1
	lhs = [0 for i in range(n)]
	for i in range(n - 1, -1, -1):
		if i == n - 1 or seq[i] >= seq[i + 1]:
			lhs[i] = 1
		else:
			lhs[i] = lhs[i + 1] + 1
	ans = max(rhs[0] + 1, lhs[n - 1] + 1)
	for i in range(1, n - 1):
		if seq[i - 1] + 1 < seq[i + 1]:
			ans = max(ans, rhs[i - 1] + lhs[i + 1] + 1)
		else:
			ans = max(ans, max(rhs[i], lhs[i]) + 1)
	print(ans)
tcs = 1
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


n = int(input())
nums = list(map(int, input().split()))
left = [1] * n
right = [1] * n
res = 1
for i in range(1, n):
	if nums[i - 1] < nums[i]:
		left[i] = left[i - 1] + 1
		res = max(res, left[i])
for i in range(n - 2, -1, -1):
	if nums[i] < nums[i + 1]:
		right[i] = right[i + 1] + 1
		res = max(res, right[i])
if res != n:
	res += 1
for i in range(1, n - 1):
	if nums[i - 1] + 1 < nums[i + 1]:
		res = max(res, left[i - 1] + right[i + 1] + 1)
print(res)


n = int(input())
Ar = [int(0)] * (n + 5)
A = [int(0)] * (n + 5)
i = 1
res = 0
for x in input().split():
	Ar[i] = int(x)
	A[i] = 1
	if Ar[i] > Ar[i - 1]:
		A[i] = A[i - 1] + 1
	i += 1
for i in range(1, n + 1):
	res = max(res, min(A[i] + 1, n))
	if Ar[i - A[i] + 1] > Ar[i - A[i] - 1] + 1:
		res = max(res, A[i] + A[i - A[i]])
	if Ar[i - A[i] + 2] > Ar[i - A[i]] + 1:
		res = max(res, A[i] + A[i - A[i]])
print(res)


import math, sys, bisect, heapq, os
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
from functools import lru_cache
int1 = lambda x: int(x) - 1

def input():
	return sys.stdin.readline().rstrip('\r\n')
aj = lambda : list(map(int, input().split()))

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])

def solve():
	(n,) = aj()
	A = aj()
	if n <= 2:
		print(n)
		exit(0)
	ans = 1
	chng = 0
	i = 0
	prev = -1
	while i < n:
		i = chng
		temp = 1
		j = chng + 1
		chance = 1
		while j < n:
			if A[j] > A[j - 1]:
				temp += 1
				prev = A[j - 1]
				ans = max(ans, temp)
				if i != 0 and chance:
					ans = max(ans, temp + 1)
			elif chance:
				chng = j
				chance = 0
				temp += 1
				ans = max(ans, temp)
				if prev < A[j] - 1:
					prev = A[j] - 1
				elif j == n - 1 or A[j - 1] + 1 < A[j + 1]:
					prev = A[j - 1]
				else:
					break
			else:
				break
			j += 1
		if j >= n:
			break
		i += 1
	print(ans)
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
solve()


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)
	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
	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())
A = list(map(int, input().split()))
subseg = []
start = 0
for i in range(N - 1):
	if A[i] >= A[i + 1]:
		subseg.append((A[start], A[i], i - start, start, i))
		start = i + 1
else:
	if N - 1 == 0:
		subseg.append((A[start], A[start], N - start - 1, start, start))
	else:
		subseg.append((A[start], A[i + 1], N - start - 1, start, i + 1))
l = len(subseg)
ans = max(subseg, key=lambda x: x[2])[2] + 1
for i in range(l):
	if i + 1 < l and subseg[i + 1][2] == 0:
		if i + 2 < l and subseg[i][1] + 2 <= subseg[i + 2][0]:
			ans = max(ans, subseg[i][2] + subseg[i + 2][2] + 3)
	if i + 1 < l and subseg[i + 1][3] + 1 < N and (subseg[i][1] + 1 < A[subseg[i + 1][3] + 1]):
		ans = max(ans, subseg[i][2] + subseg[i + 1][2] + 2)
	if i + 1 < l and 0 <= subseg[i][4] - 1 and (A[subseg[i][4] - 1] + 1 < subseg[i + 1][0]):
		ans = max(ans, subseg[i][2] + subseg[i + 1][2] + 2)
	if i != 0 or i != l - 1:
		ans = max(ans, subseg[i][2] + 2)
	else:
		ans = max(ans, subseg[i][2] + 1)
print(ans)


import sys

def answer(n, a):
	if n == 1:
		return 1
	if n == 2:
		return 2
	lord = [0 for _ in range(n)]
	lord[0] = 1
	for i in range(1, n):
		if a[i] > a[i - 1]:
			lord[i] = lord[i - 1] + 1
		else:
			lord[i] = 1
	rord = [0 for _ in range(n)]
	rord[n - 1] = 1
	for i in range(n - 2, -1, -1):
		if a[i] < a[i + 1]:
			rord[i] = rord[i + 1] + 1
		else:
			rord[i] = 1
	rep = [0 for _ in range(n)]
	rep[0] = rord[1] + 1
	rep[n - 1] = lord[n - 2] + 1
	for i in range(1, n - 1):
		rep[i] = max(lord[i - 1] + 1, rord[i + 1] + 1)
		if a[i - 1] + 1 < a[i + 1]:
			rep[i] = max(rep[i], lord[i - 1] + rord[i + 1] + 1)
	return max(rep)

def main():
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	print(answer(n, a))
	return
main()


n = int(input())
a = [int(x) for x in input().split()]
vcnt = 1
vpl = [0]
vpr = []
for i in range(1, n):
	if a[i - 1] >= a[i]:
		vcnt += 1
		vpr.append(i - 1)
		vpl.append(i)
if len(vpl) > len(vpr):
	vpr.append(n - 1)
mmax = 0
for i in range(vcnt):
	if vpr[i] - vpl[i] + 1 > mmax:
		mmax = vpr[i] - vpl[i] + 1
if mmax < len(a):
	mmax += 1
mmax1 = 0
for i in range(vcnt - 1):
	if vpr[i] - vpl[i] > 0 and vpr[i + 1] - vpl[i + 1] > 0:
		if a[vpr[i] - 1] + 1 < a[vpl[i + 1]] or a[vpr[i]] < a[vpl[i + 1] + 1] - 1:
			mm = vpr[i] - vpl[i] + vpr[i + 1] - vpl[i + 1] + 2
			if mm > mmax1:
				mmax1 = mm
if mmax1 > mmax:
	print(mmax1)
else:
	print(mmax)


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())
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]))


import math
import bisect
import itertools
import sys
I = lambda : sys.stdin.readline()
one = lambda : int(I())
more = lambda : map(int, I().split())
linput = lambda : list(more())
mod = 10 ** 9 + 7
inf = 10 ** 18 + 1

def merge(a, b):
	i = 0
	j = 0
	c = 0
	ans = []
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			ans.append(a[i])
			i += 1
		else:
			ans.append(b[j])
			c += len(a) - i
			j += 1
	ans += a[i:]
	ans += b[j:]
	return (ans, c)

def mergesort(a):
	if len(a) == 1:
		return (a, 0)
	mid = len(a) // 2
	(left, left_inversion) = mergesort(a[:mid])
	(right, right_inversion) = mergesort(a[mid:])
	(m, c) = merge(left, right)
	c += left_inversion + right_inversion
	return (m, c)

def is_prime(num):
	if num == 1:
		return False
	if num == 2:
		return True
	if num == 3:
		return True
	if num % 2 == 0:
		return False
	if num % 3 == 0:
		return False
	t = 5
	a = 2
	while t <= int(math.sqrt(num)):
		if num % t == 0:
			return False
		t += a
		a = 6 - a
	return True

def ceil(a, b):
	return (a + b - 1) // b
n = one()
a = [0] + linput()
left = [1] * (n + 1)
right = [1] * (n + 1)
if n == 1:
	print(1)
	exit()
for i in range(2, n + 1):
	if a[i] > a[i - 1]:
		left[i] = left[i - 1] + 1
	if a[-i] < a[-i + 1]:
		right[-i] = right[-i + 1] + 1
ans = max(right[1], right[2] + 1, left[n], left[n - 1] + 1, max(left), max(right))
for i in range(2, n):
	ans = max(left[i] + 1, right[i] + 1, ans)
	if a[i + 1] > a[i - 1] + 1:
		ans = max(ans, left[i - 1] + right[i + 1] + 1)
print(ans)


n = int(input())
a = list(map(int, input().split()))
a = [-1] + a + [1000000007]
maxi = 0
up = [0 for i in range(n + 2)]
down = [0 for i in range(n + 2)]
for i in range(1, n + 1):
	up[i] = up[i - 1] + 1 if a[i] > a[i - 1] else 1
for i in range(n, 0, -1):
	down[i] = down[i + 1] + 1 if a[i] < a[i + 1] else 1
for i in range(1, n + 1):
	maxi = max(maxi, up[i - 1] + (a[i - 1] + 1 < a[i + 1]) * down[i + 1] + 1)
	maxi = max(maxi, up[i - 1] * (a[i + 1] - 1 > a[i - 1]) + down[i + 1] + 1)
print(maxi)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	n = int(inp())
	a = lis()
	l = [1] * (n + 1)
	r = [1] * (n + 1)
	for i in range(1, n):
		if a[i] > a[i - 1]:
			l[i] = l[i - 1] + 1
		else:
			l[i] = 1
	for i in range(n - 2, -1, -1):
		if a[i] < a[i + 1]:
			r[i] = r[i + 1] + 1
		else:
			r[i] = 1
	ans = 1
	for i in range(n):
		ans = max(ans, l[i], r[i])
	for i in range(n):
		if i > 0:
			ans = max(ans, l[i - 1] + 1)
		if i < n - 1:
			ans = max(ans, r[i + 1] + 1)
		if i > 0 and i < n - 1 and (a[i + 1] > a[i - 1] + 1):
			ans = max(ans, l[i - 1] + r[i + 1] + 1)
	print(ans)
testcase(1)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
n = int(data())
arr = l()
if len(arr) <= 2:
	out(n)
	exit()
(suf, pref) = ([1] * n, [1] * n)
for i in range(1, n):
	if arr[i] > arr[i - 1]:
		suf[i] = suf[i - 1] + 1
for i in range(n - 2, -1, -1):
	if arr[i] < arr[i + 1]:
		pref[i] = pref[i + 1] + 1
answer = max(suf)
if answer < n:
	answer += 1
for i in range(1, n - 1):
	if arr[i - 1] + 1 < arr[i + 1]:
		answer = max(answer, suf[i - 1] + 1 + pref[i + 1])
out(answer)


from collections import deque, defaultdict
from math import sqrt, ceil, factorial, floor, inf, log2, sqrt, gcd
import bisect
import sys
import copy

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
dp = [1] * n
dp1 = [1] * n
a = get_array()
maxi = 1
max_li = 10 ** 9
for i in range(1, n):
	if a[i - 1] < a[i]:
		dp[i] = dp[i - 1] + 1
for i in range(n - 2, -1, -1):
	if a[i + 1] > a[i]:
		dp1[i] = dp1[i + 1] + 1
maxi = max(maxi, min(n, max(max(dp), max(dp1)) + 1))
for i in range(1, n - 1):
	ele = a[i + 1] - 1
	if ele > a[i - 1]:
		maxi = max(maxi, 1 + dp[i - 1] + dp1[i + 1])
print(maxi)


import sys
T = 1
for _ in range(T):
	n = int(input())
	l = list(map(int, input().split()))
	p = []
	i = 0
	j = 1
	kk = 0
	while j < n:
		if l[j] <= l[j - 1]:
			p.append((i, j - 1))
			if j - i > kk:
				kk = j - i
			i = j
		j += 1
	p.append((i, j - 1))
	if j - i > kk:
		kk = j - i
	ans = 0
	if len(p) == 1:
		ans = n
	else:
		ans = kk + 1
	for i in range(len(p) - 1):
		t1 = p[i]
		t2 = p[i + 1]
		(i1, i2) = (t1[0], t1[1])
		(j1, j2) = (t2[0], t2[1])
		if i1 == i2 or j1 == j2:
			q = j2 - i1 + 1
			if q > ans:
				ans = q
		elif l[j1] - l[i2 - 1] >= 2 or l[j1 + 1] - l[i2] >= 2:
			q = j2 - i1 + 1
			if q > ans:
				ans = q
	print(ans)


from __future__ import print_function
from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(n,) = gil()
a = gil()
ans = 1
(l, r) = ([1] * n, [1] * n)
for i in range(1, n):
	if a[i] > a[i - 1]:
		l[i] += l[i - 1]
	ans = max(ans, l[i] + 1)
for i in reversed(range(n - 1)):
	if a[i] < a[i + 1]:
		r[i] += r[i + 1]
	ans = max(ans, r[i] + 1)
ans = min(ans, n)
for i in range(1, n - 1):
	if a[i + 1] - a[i - 1] > 1:
		ans = max(ans, r[i + 1] + l[i - 1] + 1)
print(ans)


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)


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


n = int(input())
vec = list(map(int, input().split()))
status = [1] * (n + 1)
for i in range(1, n):
	if vec[i] > vec[i - 1]:
		status[i] = status[i - 1] + 1
far = [1] * (n + 1)
cur = status[n - 1]
for i in range(n - 2, -1, -1):
	if vec[i] < vec[i + 1]:
		far[i] += cur - status[i]
	else:
		cur = status[i]
ans = max(status)
for i in range(n):
	if i == 0:
		if i + 1 < n and vec[i + 1] != 1:
			ans = max(ans, far[i + 1] + 1)
	elif i == n - 1:
		ans = max(ans, status[i - 1] + 1)
	elif vec[i + 1] - vec[i - 1] > 1:
		if far[i] == 1:
			ans = max(ans, status[i - 1] + far[i + 1] + 1)
		else:
			ans = max(ans, status[i - 1] + far[i])
	else:
		ans = max(ans, status[i] + 1)
		if vec[i + 1] != 1:
			ans = max(ans, far[i] + 1)
print(ans)


n = int(input())
arr = list(map(int, input().split()))
pre = [0 for i in range(n)]
pre[-1] = 1
for i in range(n - 2, -1, -1):
	if arr[i + 1] > arr[i]:
		pre[i] = pre[i + 1] + 1
	else:
		pre[i] = 1
ans = 0
for i in range(n):
	last1 = arr[i + pre[i] - 1]
	ans = max(ans, pre[i])
	if pre[i] == 1:
		if i + 1 < n:
			ans = max(ans, pre[i + 1] + 1)
	elif i + pre[i] < n:
		if arr[i + pre[i]] > last1:
			ans = max(ans, pre[i] + pre[i + pre[i]])
		elif pre[i + pre[i]] == 1:
			ans = max(ans, pre[i] + 1)
		else:
			if arr[i + pre[i] + 1] - last1 >= 2:
				ans = max(ans, pre[i] + pre[i + pre[i]])
			if last1 + 1 >= arr[i + pre[i] + 1]:
				ans = max(ans, pre[i] + 1)
			if arr[i + pre[i]] - arr[i + pre[i] - 2] >= 2:
				ans = max(ans, pre[i] + pre[i + pre[i]])
print(ans)


def canMerge(seq1, seq2):
	if len(seq2) == 1:
		return True
	last = seq1[-1]
	second = seq2[1]
	if second - last > 1:
		return True
	if len(seq1) == 1:
		return True
	second_last = seq1[-2]
	first = seq2[0]
	if first - second_last > 1:
		return True
	return False

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	sequences = []
	seq = [arr[0]]
	for i in range(1, n):
		if arr[i] > seq[-1]:
			seq.append(arr[i])
		else:
			sequences.append(seq)
			seq = [arr[i]]
	sequences.append(seq)
	ans = len(sequences[-1])
	for i in range(len(sequences) - 1):
		seq1 = sequences[i]
		seq2 = sequences[i + 1]
		ans = max(ans, len(seq1) + 1, len(seq2) + 1)
		if canMerge(seq1, seq2):
			ans = max(ans, len(seq1) + len(seq2))
	print(ans)
main()


n = int(input())
arr = [int(var) for var in input().split()]
maxLeft = [1 for _ in range(n)]
maxRight = [1 for _ in range(n)]
ans = 1
for i in range(1, n):
	if arr[i] > arr[i - 1]:
		maxLeft[i] = maxLeft[i - 1] + 1
for i in reversed(range(n - 1)):
	if arr[i] < arr[i + 1]:
		maxRight[i] = maxRight[i + 1] + 1
for i in range(n):
	(prev, next) = (arr[i - 1] if i - 1 >= 0 else -float('inf'), arr[i + 1] if i + 1 < n else float('inf'))
	leftSubArray = maxLeft[i - 1] if i - 1 >= 0 else 0
	rightSubArray = maxRight[i + 1] if i + 1 < n else 0
	if not prev < arr[i] < next:
		if next - prev >= 2:
			ans = max(ans, rightSubArray + leftSubArray + 1)
		else:
			ans = max(ans, leftSubArray + 1, 1 + rightSubArray)
	else:
		ans = max(ans, rightSubArray + leftSubArray + 1)
print(ans)


import sys
num = int(input())
seq = [-1] + list(map(int, input().split())) + [sys.maxsize]
maxi = 0
forward = [0 for i in range(num + 2)]
back = [0 for i in range(num + 2)]
for i in range(1, num + 1):
	forward[i] = forward[i - 1] + 1 if seq[i] > seq[i - 1] else 1
for i in range(num, 0, -1):
	back[i] = back[i + 1] + 1 if seq[i] < seq[i + 1] else 1
for i in range(1, num + 1):
	maxi = max(maxi, forward[i - 1] + (seq[i - 1] + 1 < seq[i + 1]) * back[i + 1] + 1)
	maxi = max(maxi, forward[i - 1] * (seq[i + 1] - 1 > seq[i - 1]) + back[i + 1] + 1)
print(maxi)


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
	for i in range(ints - 1):
		if nums[i + 1] > nums[i]:
			left[i + 1] += left[i]
	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 = [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)


def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def msi():
	return map(str, input().split())

def li():
	return list(mi())
n = ii()
a = li()
(pre, suf) = ([1] * n, [1] * n)
for i in range(1, n):
	if a[i] > a[i - 1]:
		pre[i] += pre[i - 1]
for i in range(n - 2, -1, -1):
	if a[i] < a[i + 1]:
		suf[i] += suf[i + 1]
ans = max(pre)
if ans < n:
	ans += 1
for i in range(1, n - 1):
	if a[i + 1] > a[i - 1] + 1:
		ans = max(ans, pre[i - 1] + suf[i + 1] + 1)
print(ans)


import sys
n = int(input())
s = list(map(int, input().split()))
a = [0] * n
b = [0] * n
a[0] = 1
b[0] = 1
if n == 1:
	print(1)
	sys.exit()
for i in range(1, n):
	if s[i] > s[i - 1]:
		a[i] = a[i - 1] + 1
	else:
		a[i] = 1
s = s[::-1]
for i in range(1, n):
	if s[i] < s[i - 1]:
		b[i] = b[i - 1] + 1
	else:
		b[i] = 1
s = s[::-1]
b = b[::-1]
ans = b[1] + 1
for i in range(1, n - 1):
	if s[i - 1] + 1 < s[i + 1]:
		ans = max(ans, a[i - 1] + 1 + b[i + 1])
	else:
		ans = max(ans, a[i - 1] + 1, 1 + b[i + 1])
ans = max(ans, a[n - 2] + 1)
print(ans)


n = int(input())
a = [0] + list(map(int, input().split()))
start = [0] * (n + 1)
end = [0] * (n + 1)
(s, e) = (1, 1)
for i in range(2, n + 1):
	e += 1
	if a[i] <= a[i - 1]:
		start[s:e] = [s] * (e - s)
		end[s:e] = [e - 1] * (e - s)
		s = e
start[s:] = [s] * (n - s + 1)
end[s:] = [n] * (n - s + 1)
best = 1
for i in range(2, n):
	if a[i - 1] + 1 < a[i + 1]:
		best = max(best, end[i + 1] - start[i - 1] + 1)
	else:
		best = max(best, i - start[i - 1] + 1, end[i + 1] - i + 1)
if n != 1:
	best = max(best, n - start[n - 1] + 1, end[2])
print(best)


def find_inc_seq(n, nums):
	max_found = 1 if n else 0
	dp = [[1] * 2 for _ in range(n)]
	dp[0][0] = 0
	for i in range(2, n):
		if nums[i - 1] > nums[i - 2]:
			dp[i][0] = dp[i - 1][0] + 1
	dp[n - 1][1] = 0
	for i in range(n - 3, -1, -1):
		if nums[i + 1] < nums[i + 2]:
			dp[i][1] = dp[i + 1][1] + 1
	for i in range(n):
		max_found = max(max_found, max(dp[i]) + 1)
		if i and i < n - 1 and (nums[i + 1] - nums[i - 1] > 1):
			max_found = max(max_found, dp[i][0] + dp[i][1] + 1)
	return max_found
n = int(input())
nums = list(map(int, input().split()))
ans = find_inc_seq(n, nums)
print(ans)


n = int(input())
a = [0] + list(map(int, input().split())) + [0]
l = []
st = 1
for i in range(2, n + 2):
	if a[i] <= a[i - 1]:
		l.append([st, i - 1])
		st = i
if len(l) == 1:
	print(n)
	exit()
mx = 0
for i in range(1, len(l)):
	lf = l[i - 1][1]
	rt = l[i][0]
	ln1 = l[i][1] - l[i][0] + 1
	ln2 = l[i - 1][1] - l[i - 1][0] + 1
	if a[rt + 1] - a[lf] > 1 or a[rt] - a[lf - 1] > 1:
		tm = ln1 + ln2
	else:
		tm = max(ln1, ln2) + 1
	mx = max(mx, tm)
print(mx)


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:
			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())
if n <= 2:
	print(n)
else:
	al = list(map(int, input().split()))
	sta = 0
	nextsta = sta + 1
	l = 0
	while sta < n:
		count = 0
		last = al[sta]
		nextsta = sta + 1
		for end in range(nextsta, n):
			if al[end] > last:
				last = al[end]
			elif count == 0:
				if end - sta >= 2 and al[end] - al[end - 2] >= 2:
					last = al[end]
				else:
					last += 1
				count += 1
				nextsta = end
			else:
				l = max(l, end - sta)
				if nextsta > sta + 1:
					nextend = max(nextsta + 1, end - 1)
				else:
					nextend = nextsta + 1
				break
			if end == n - 1:
				if count == 0 and sta >= 1:
					l = max(l, n + 1 - sta)
				else:
					l = max(l, n - sta)
				nextsta = n
		sta = nextsta
	print(l)


from collections import deque
from collections import OrderedDict
import math
import sys
import os
import threading
import bisect
import operator
import heapq
from atexit import register
from io import BytesIO
import io
input = lambda : sys.stdin.readline().rstrip('\r\n')

def fun1(i, k):
	if i <= k:
		return i
	else:
		return k - (i - k)
n = int(input())
ar = [0] + list(map(int, input().split()))
dpI = [1] * (n + 5)
dpU = [1] * (n + 5)
answer = 1
for i in range(2, n + 1):
	if ar[i - 1] < ar[i]:
		dpI[i] += dpI[i - 1]
	answer = max(answer, dpI[i])
for i in range(n - 1, 0, -1):
	if ar[i + 1] > ar[i]:
		dpU[i] += dpU[i + 1]
preAnswer = answer
for i in range(2, n):
	if ar[i - 1] < ar[i + 1] and ar[i + 1] - ar[i - 1] > 1:
		temp = dpI[i - 1] + dpU[i + 1] + 1
		answer = max(answer, temp)
if preAnswer == answer:
	answer = min(n, answer + 1)
print(answer)
sys.exit(0)

def gcs(a, b):
	n = len(a)
	m = len(b)
	f = [[0] * (n + 1) for i in range(m + 1)]
	for i in range(1, n):
		for j in range(1, m):
			if a[i] == b[j]:
				f[i][j] = f[i - 1][j - 1] + 1
			else:
				f[i][j] = max(f[i - 1][j], f[i][j - 1])
	(i, j, l) = (n - 1, m - 1, 0)
	answer = []
	while i != 0:
		if f[i][j] == f[i - 1][j] + 1 and f[i][j] == f[i][j - 1] + 1:
			print(i, j, l)
			answer.append(a[i])
			i -= 1
			l = j - 1
		j -= 1
		if j == 0:
			i -= 1
			j = l
	for i in range(0, n):
		for j in range(0, m):
			print(f[i][j], end=' ')
		print('\n', end='')
	print(answer)
	return f[n - 1][m - 1]
print(gcs('1baccbca', '2abcabaac'))
for t in range(int(input())):
	n = int(input())
	ar1 = [' '] + list(map(str, input().split()))
	ar2 = [' '] + list(map(str, input().split()))
	dp = [[0] * (n + 1) for i in range(n + 1)]
	for i in range(1, n + 1):
		for j in range(1, n + 1):
			dp[i][j] = dp[i - 1][j]
			if ar1[i] == ar2[j]:
				dp[i][j] = dp[i - 1][j - 1] + 1
			else:
				dp[i][j] = max(dp[i][j - 1], dp[i - 1][j])


from heapq import heapify, heappush, heappop
from collections import Counter, defaultdict, deque, OrderedDict
from sys import setrecursionlimit, maxsize
from bisect import bisect_left, bisect, insort_left, insort
from math import ceil, log, factorial, hypot, pi
from fractions import gcd
from copy import deepcopy
from functools import reduce
from operator import mul
from itertools import product, permutations, combinations, accumulate, cycle
from string import ascii_uppercase, ascii_lowercase, ascii_letters, digits, hexdigits, octdigits
prod = lambda l: reduce(mul, l)
prodmod = lambda l, mod: reduce(lambda x, y: mul(x, y) % mod, l)

def read_list(t):
	return [t(x) for x in input().split()]

def read_line(t):
	return t(input())

def read_lines(t, N):
	return [t(input()) for _ in range(N)]
N = read_line(int)
array = read_list(int)
i = 0
inc_subsegments = []
while i < N:
	start = i
	while i + 1 < N and array[i] < array[i + 1]:
		i += 1
	if i != start:
		inc_subsegments.append((start, i))
	i += 1
ans = max(min(2, N), max((min(end - start + 1 + 1, N) for (start, end) in inc_subsegments)) if inc_subsegments else 0)
for i in range(len(inc_subsegments) - 1):
	i_last = inc_subsegments[i][1]
	i_next_first = inc_subsegments[i + 1][0]
	if i_last + 1 == i_next_first and (array[i_next_first + 1] - array[i_last] > 1 or array[i_next_first] - array[i_last - 1] > 1):
		ans = max(ans, inc_subsegments[i + 1][1] - inc_subsegments[i][0] + 1)
print(ans)