#CRT0001. Gaster の 01序列

Gaster の 01序列

Problem Background

sanssans went to the Monster Academy to steal some questions again, and then handed them over to GasterGaster. GasterGaster hopes you can help him.

Problem Description

Given a sequence of length nn, please find the longest contiguous subsequence where the difference between the maximum and minimum numbers in this subsequence is not greater than 1. This subsequence is called a "01 difference" subsequence.

Ensure that the data meets the condition ai+1ai1|a_{i+1} - a_{i}| \le 1, meaning the difference between any two adjacent numbers is less than or equal to 1.

Input Format

The first line contains an integer nn (2n105)(2\le n\le 10^5) — the size of the sequence.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai100000)(1\le a_i \le 100000).

Output Format

The length of the longest "01" subsequence.

Examples

Input Example 1

5
1 2 3 3 2

Output Example 1

4

The longest "01" subsequence is [2, 3, 3, 2]. It has a length of 4.

Input Example 2

8
1 2 1 2 1 2 3 2

Output Example 2

6

The longest "01" subsequence is [1, 2, 1, 2, 1, 2]. It has a length of 6.