import java.util.Arrays; import java.util.Scanner; public class Main { void run() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] A = new int[N]; for (int i = 0; i < N; ++i) { A[i] = sc.nextInt(); } long[][] dp1 = new long[N][N]; long[][] dp2 = new long[N][N]; for (int i = 0; i < N; ++i) { dp1[i][i] = 1; dp2[i][i] = 1; } for (int d = 0; d < N; ++d) { for (int i = 0; i + d < N; ++i) { if (i + d + 1 < N) dp1[i][i + d + 1] = Math.max(dp1[i][i + d + 1], dp1[i][i + d]); if (i - 1 >= 0) dp2[i - 1][i + d] = Math.max(dp2[i - 1][i + d], dp2[i][i + d]); if (i + d + 1 < N && A[i + d + 1] < A[i]) { dp2[i][i + d + 1] = Math.max(dp2[i][i + d + 1], dp1[i][i + d] + 1); } if (i - 1 >= 0 && A[i + d] > A[i - 1]) { dp1[i - 1][i + d] = Math.max(dp1[i - 1][i + d], dp2[i][i + d] + 1); } } } long ans = 0; for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) { ans = Math.max(ans, dp1[i][j]); ans = Math.max(ans, dp2[i][j]); } System.out.println(ans); } public static void main(String[] args) { new Main().run(); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }