When Xellos was doing a practice course in university, he once had to measure the intensity of an effect that slowly approached equilibrium. A good way to determine the equilibrium intensity would be choosing a sufficiently large number of consecutive data points that seems as constant as possible and taking their average. Of course, with the usual sizes of data, it's nothing challenging — but why not make a similar programming contest problem while we're at it?

You're given a sequence of n data points a1, ..., an. There aren't any big jumps between consecutive data points — for each 1 ≤ i < n, it's guaranteed that |ai + 1 - ai| ≤ 1.

A range [l, r] of data points is said to be almost constant if the difference between the largest and the smallest value in that range is at most 1. Formally, let M be the maximum and m the minimum value of ai for l ≤ i ≤ r; the range [l, r] is almost constant if M - m ≤ 1.

Find the length of the longest almost constant range.

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of data points.

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 100 000).

Output

Print a single number — the maximum length of an almost constant range of the given sequence.

Examples

Input

5
1 2 3 3 2


Output

4


Input

11
5 4 5 5 6 7 8 8 8 7 6


Output

5

Note

In the first sample, the longest almost constant range is [2, 5]; its length (the number of data points in it) is 4.

In the second sample, there are three almost constant ranges of length 4: [1, 4], [6, 9] and [7, 10]; the only almost constant range of the maximum length 5 is [6, 10].
#!/usr/bin/env python3
# 602B_approx.py - Codeforces.com/problemset/problem/602/B by Sergey 2015

import unittest
import sys

###############################################################################
# Approx Class (Main Program)
###############################################################################


class Approx:
    """ Approx representation """

    def __init__(self, test_inputs=None):
        """ Default constructor """

        it = iter(test_inputs.split("\n")) if test_inputs else None

        def uinput():
            return next(it) if it else sys.stdin.readline().rstrip()

        # Reading single elements
        [self.n] = map(int, uinput().split())

        # Reading a single line of multiple elements
        self.nums = list(map(int, uinput().split()))

    def calculate(self):
        """ Main calcualtion function of the class """

        result = 1
        so_far = 1
        nmax, nmin = self.nums[0], self.nums[0]
        prev = self.nums[0]
        prevrep = 1
        for n in self.nums[1:]:
            if abs(n - nmax) > 1 or abs(n - nmin) > 1:
                so_far = prevrep + 1
                nmax = max(n, prev)
                nmin = min(n, prev)
            else:
                so_far += 1
                nmax = max(nmax, n)
                nmin = min(nmin, n)
            result = max(result, so_far)
            if n == prev:
                prevrep += 1
            else:
                prevrep = 1
            prev = n

        return str(result)

###############################################################################
# Unit Tests
###############################################################################


class unitTests(unittest.TestCase):

    def test_single_test(self):
        """ Approx class testing """

        # Constructor test
        test = "5\n1 2 3 3 2"
        d = Approx(test)
        self.assertEqual(d.n, 5)
        self.assertEqual(d.nums, [1, 2, 3, 3, 2])

        # Sample test
        self.assertEqual(Approx(test).calculate(), "4")

        # Sample test
        test = "11\n5 4 5 5 6 7 8 8 8 7 6"
        self.assertEqual(Approx(test).calculate(), "5")

        # Sample test
        test = "1\n2 3 4 5 4 4 3 4 4"
        self.assertEqual(Approx(test).calculate(), "5")

        # My tests
        test = ""
        # self.assertEqual(Approx(test).calculate(), "0")

        # Time limit test
        # self.time_limit_test(5000)

    def time_limit_test(self, nmax):
        """ Timelimit testing """
        import random
        import timeit

        # Random inputs
        test = str(nmax) + " " + str(nmax) + "\n"
        numnums = [str(i) + " " + str(i+1) for i in range(nmax)]
        test += "\n".join(numnums) + "\n"
        nums = [random.randint(1, 10000) for i in range(nmax)]
        test += " ".join(map(str, nums)) + "\n"

        # Run the test
        start = timeit.default_timer()
        d = Approx(test)
        calc = timeit.default_timer()
        d.calculate()
        stop = timeit.default_timer()
        print("\nTimelimit Test: " +
              "{0:.3f}s (init {1:.3f}s calc {2:.3f}s)".
              format(stop-start, calc-start, stop-calc))

if __name__ == "__main__":

    # Avoiding recursion limitaions
    sys.setrecursionlimit(100000)

    if sys.argv[-1] == "-ut":
        unittest.main(argv=[" "])

    # Print the result string
    sys.stdout.write(Approx().calculate())
