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.util.Stack;
import java.util.StringTokenizer;

public class B {
    static private BufferedReader in;
    static private PrintWriter out;

    static {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter(new FileWriter("output.txt"));
        } catch (Exception ex) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
    }
    static StringTokenizer tokenizer;
    static private String nextString() {
        while (tokenizer == null || !tokenizer.hasMoreElements()) {
            try {
                tokenizer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                System.err.println("Trouble in reading");
            }
        }
        return tokenizer.nextToken();
    }
    static private int nextInt() {
        return Integer.valueOf(nextString());
    }
    static private long nextLong() {
        return Long.valueOf(nextString());
    }

    static void solve() {
        int n = nextInt();
        Queue q = new Queue();
        int maxLength = 1;
        for (int i = 0; i < n; i++) {
            int d = nextInt();
            maxLength = Math.max(maxLength, q.in.size()+q.out.size());
            try {
                while(true) {
                    int tmin = Math.min(q.peek().min, d);
                    int tmax = Math.max(q.peek().max, d);
                    if (tmax - tmin > 1) {
                        q.pop();
                    }
                    else break;
                }
            } catch (Exception ex) {}
            q.push(q.in, d);
        }
        if (q.peek().max - q.peek().min < 2)
            maxLength = Math.max(maxLength, q.in.size()+q.out.size());
        out.print(maxLength);
        close();
    }

    public static void close() {
        if (out != null) out.close();
        if (in != null) try {
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        solve();
    }
}

class Queue {
    public Stack<Pair> in;
    Stack<Pair> out;

    Queue() {
        in = new Stack<>();
        out = new Stack<>();
    }

    void push(Stack<Pair> in, int a) {
        Pair p = new Pair(a, a, a);
        if (in.isEmpty()) in.push(p);
        else {
            p.min = Math.min(p.min, in.peek().min);
            p.max = Math.max(p.max, in.peek().max);
            in.push(p);
        }
    }

    void push(Stack<Pair> in, Pair p) {
        p.min = p.a;
        p.max = p.a;
        if (in.isEmpty()) in.push(p);
        else {
            p.min = Math.min(p.min, in.peek().min);
            p.max = Math.max(p.max, in.peek().max);
            in.push(p);
        }
    }

    Pair pop() {
        if (out.isEmpty()) {
            while(!in.isEmpty()) push(out, in.pop());
        }
        return out.pop();
    }

    Pair peek() {
        if (out.isEmpty()) {
            return in.peek();
        }
        Pair res = new Pair(0,0,0);
        res.min = Math.min(in.peek().min, out.peek().min);
        res.max = Math.max(in.peek().max, out.peek().max);
        return res;
    }
}

class Pair {
    int a;
    int min;
    int max;

    public Pair(int a, int min, int max) {
        this.a = a;
        this.min = min;
        this.max = max;
    }

    @Override
    public String toString() {
        return "Pair{" +
                "a=" + a +
                ", min=" + min +
                ", max=" + max +
                '}';
    }
}