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

import java.io.*;
import java.lang.reflect.Array;
import java.math.*;
import java.util.*;
import java.util.regex.Pattern;

@SuppressWarnings("Duplicates")
// author @mdazmat9

public class codeforces{
    static int abs=1000000007;
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] args) throws IOException {
        int test =1;

        for (int ind = 0; ind < test; ind++) {
            int n = sc.nextInt();
            int [] a=new int[n];
            for(int i=0;i<n;i++)a[i]=sc.nextInt();
            
            out.println(util(a));
        }

        out.flush();
    }
    public static int util(int[] a){
        TreeMap<Integer,Integer> map=new TreeMap<>();
        int s=0;
        int n=a.length;
        int len=Integer.MIN_VALUE;
        for(int e=0;e<n;e++){
            if(map.containsKey(a[e]))
                map.put(a[e],map.get(a[e])+1);
            else
                map.put(a[e],1);
            while(s<=e && map.lastKey()-map.firstKey()>1){
                if(map.get(a[s])==1)
                    map.remove(a[s]);
                else
                    map.put(a[s],map.get(a[s])-1);
                s++;
            }
            if(e-s+1>len)
                len=e-s+1;
        }
        return len;
    }


    public static double logb( double a, double b )
    {
        return Math.log(a) / Math.log(b);
    }

    static long fast_pow(long a, long b) {
        if(b == 0)
            return 1L;

        long val = fast_pow(a, b / 2);

        if(b % 2 == 0)
            return val * val % mod;
        else
            return val * val % mod * a % mod;
    }
    static long mod = (long)1e9 + 7;
    static   void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    static long gcd(long a , long b)
    {
        if(b == 0)
            return a;
        return gcd(b , a % b);
    }

}
class Scanner {
    public BufferedReader reader;
    public StringTokenizer st;

    public Scanner(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        st = null;
    }

    public String next() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = reader.readLine();
                if (line == null) return null;
                st = new StringTokenizer(line);
            } catch (Exception e) {
                throw (new RuntimeException());
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

class OutputWriter {
    BufferedWriter writer;

    public OutputWriter(OutputStream stream) {
        writer = new BufferedWriter(new OutputStreamWriter(stream));
    }

    public void print(int i) throws IOException {
        writer.write(i);
    }

    public void print(String s) throws IOException {
        writer.write(s);
    }

    public void print(char[] c) throws IOException {
        writer.write(c);
    }

    public void close() throws IOException {
        writer.close();
    }

}
class Pair {
    int x;
    int y;

    // Constructor
    public Pair(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
}
class Compare {

    static void compare(Pair arr[], int n)
    {
        // Comparator to sort the pair according to second element
        Arrays.sort(arr, new Comparator<Pair>() {
            @Override public int compare(Pair p1, Pair p2)
            {
                return (p1.x - p2.x);
            }
        });
    }
}

class Graph {

    int V;
    ArrayList<Integer>[] adjListArray;


    // constructor
    Graph(int V) {
        this.V = V;

        adjListArray = new ArrayList[V];

        for (int i = 0; i < V; i++) {
            adjListArray[i] = new ArrayList<>();
        }
    }

    // Adds an edge to an undirected graph
    void addEdge(int src, int dest) {

        adjListArray[src].add(dest);
        adjListArray[dest].add(src);
    }


    void DFSUtil(int v, boolean[] visited,int ind) {
        // Mark the current node as visited and print it
        visited[v] = true;
        // System.out.print(v+" ");
        list[ind].add(v);

        // Recur for all the vertices
        // adjacent to this vertex
        for (int x : adjListArray[v]) {
            if(!visited[x]) DFSUtil(x,visited,ind);
        }

    }
    static  ArrayList[] list;
    void connectedComponents() {
        // Mark all the vertices as not visited
        list=new ArrayList[V];
        for(int i=0;i<V;i++)list[i]=new ArrayList();
        boolean[] visited = new boolean[V];
        int index=0;
        for(int v = 0; v < V; ++v) {
            if(!visited[v]) {
                // print all reachable vertices
                // from v
                DFSUtil(v,visited,index++);
            }
        }
        int [] a=new int[V];
        index=0;
        while (true){
            if(list[index].size()==0)
                break;
            for(int i=0;i<list[index].size();i++){
                a[(int)list[index].get(i)]=list[index].size();
            }
            index++;
        }
        for (int i=0;i<V;i++)
            System.out.print(a[i]+" ");
    }


}