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.util.*;
import java.io.*;
public class Main{	
	public static void main(String args[]) {
		InputReader in =new InputReader(System.in);
		int n=in.nextInt();
		int min=0,max=0,start=0;
		int a[]=new int[n],ans=1;
		a[0]=in.nextInt();
		min=max=a[0];
		int b[]=new int[100001];
		b[a[0]]=0;
		for(int i=1;i<n;i++) {
			a[i]=in.nextInt();
			if(min-a[i]>1) {
				start=i;
				
				max=min=i;
			}
			else if(a[i]-max>1) {
				max=min=i;
				start=i;
			}
			else if(max-a[i]==2) {
				start=b[max]+1;
				max=min;
				min=a[i];//System.out.println("c");
			}
			else if(a[i]-min==2) {
				start=b[min]+1;
				min=max;
				max=a[i];//System.out.println("d");
			}
			max=Math.max(a[i],max);
			min=Math.min(a[i], min);
			b[a[i]]=i;
			//System.out.println(start);
			ans=Math.max(ans,i-start+1);
		}
		System.out.println(ans);
	}
	/*static int n,m;
	static boolean isCycle=false;
	static int leaves;
	public static void main(String args[]) {
		InputReader in=new InputReader(System.in);
		int t=in.nextInt();
		while(t>0) {
			leaves=0;
			int n=in.nextInt(),m=in.nextInt(),ans=0;
			ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
			ArrayList<ArrayList<Integer>> rlist= new ArrayList<ArrayList<Integer>>();
			ArrayList<ArrayList<Integer>> _list = new ArrayList<ArrayList<Integer>>();
			ArrayList<ArrayList<Integer>> _rlist= new ArrayList<ArrayList<Integer>>();
			for(int i=0;i<=n;i++) {
				list.add(i,new ArrayList<Integer>());
				rlist.add(i,new ArrayList<Integer>());
				_list.add(i,new ArrayList<Integer>());
				_rlist.add(i,new ArrayList<Integer>());
			}
			for(int i=0;i<m;i++) {
				int a=in.nextInt(),b=in.nextInt();
				list.get(a).add(b);
				rlist.get(b).add(a);
			}
			Stack<Integer> st = new Stack<Integer>();
			boolean visited[]=new boolean[n+1];
			for(int i=1;i<=n;i++) {
				if(!visited[i])
					dfs1(i,st,visited,list);
			}
			visited=new boolean[n+1];
			int scc[]=new int [n+1],num=1;
			while(!st.isEmpty()) {
				int i=st.pop();
				if(!visited[i]) {
					dfs2(i,visited,rlist,num,scc);
					num++;
				}
			}
			
			for(int i=1;i<=n;i++) {
				Iterator<Integer> it=list.get(i).iterator();
				while(it.hasNext()) {
					int j=it.next();
					if(scc[i]!=scc[j]) {
						_list.get(scc[i]).add(scc[j]);
						_list.get(scc[j]).add(scc[i]);
					}
				}
			}
			int cn=0;
			visited=new boolean[num+1];
			for(int i=1;i<num;i++) {
				if(!visited[i]) {
					dfs3(i,visited,_list,i);
					leaves--;
					cn++;
				}
			}
			if(cn>1) leaves+=cn;
			System.out.println(leaves);
			t--;
		}
	}
	public static void dfs1(int v, Stack<Integer> st,boolean[] visited,ArrayList<ArrayList<Integer>> list){
		visited[v]=true;
		Iterator<Integer> it= list.get(v).iterator();
		while(it.hasNext()) {
			int u=it.next();
			if(!visited[u]) {
				dfs1(u,st,visited,list);
			}
		}
		st.push(v);
	}
	public static void dfs2(int v,boolean[] visited,ArrayList<ArrayList<Integer>> list,int num,int scc[]) {
		visited[v]=true;
		scc[v]=num;
		Iterator<Integer> it= list.get(v).iterator();
		while(it.hasNext()) {
			int u=it.next();
			if(!visited[u]) {
				dfs2(u,visited,list,num,scc);
			}
		}
	}
	public static void dfs3(int v,boolean[] visited,ArrayList<ArrayList<Integer>> list,int root) {
		visited[v]=true;
		int cn=0;
		Iterator<Integer> it= list.get(v).iterator();
		while(it.hasNext()) {
			int u=it.next();
			if(!visited[u]) {
				cn++;
				dfs3(u,visited,list,root);
			}
		}
		if(cn<2) leaves++;
	}
	

	
	/*public static void main(String args[]) {
		InputReader in = new InputReader(System.in);
		ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
		ArrayList<ArrayList<Integer>> rlist = new ArrayList<ArrayList<Integer>>();
		n=in.nextInt();m=in.nextInt();
		for(int i=0;i<=n;i++) {
			list.add(i,new ArrayList<Integer>());
			rlist.add(i,new ArrayList<Integer>());
		}
		for(int i=0;i<m;i++) {
			int a=in.nextInt(),b=in.nextInt();
			list.get(a).add(b);
			rlist.get(b).add(a);
		}
		int scc[]=new int[n+1];
		Stack<Integer> stack =new Stack<Integer>();
		int cc[]=new int[n+1],count[]=new int[n+2],num=1,comp=1;
		for(int i=1;i<=n;i++) {
			if(cc[i]==0) {
				dfs1(i,list,cc,comp,stack);
				comp++;
			}
		}
		while(!stack.isEmpty()) {
			int i=stack.pop();
			if(scc[i]==0) {
				count[num]=dfs2(i,rlist,num,scc);
				num++;
			}
		}
		
		ArrayList<ArrayList<Integer>> sccList=new ArrayList<ArrayList<Integer>>();
		for(int i=0;i<=num;i++)
			sccList.add(i,new ArrayList<Integer>());
		for(int i=1;i<=n;i++) {
			Iterator<Integer> it=list.get(i).iterator();
			while(it.hasNext()) {
				int e=it.next();
				sccList.get(scc[i]).add(scc[e]);
				sccList.get(scc[e]).add(scc[i]);
			}
		}
		int ans=0;
		boolean visited[]=new boolean[num+1];
		for(int i=1;i<num;i++) {
			if(!visited[i]) {
				ans +=dfs3(i,sccList,visited,count);
				ans += isCycle?0:-1;
			}
			isCycle=false;
		}
		System.out.println(ans);
		
	}
	public static void dfs1(int v,ArrayList<ArrayList<Integer>> list,int [] cc,int comp,Stack<Integer> stack) {
		cc[v]=comp;
		Iterator<Integer> it=list.get(v).iterator();
		while(it.hasNext()) {
			int e=it.next();
			if(cc[e]==0)
				dfs1(e,list,cc,comp,stack);
		}
		stack.add(v);
	}
	public static int dfs2(int v,ArrayList<ArrayList<Integer>> rlist,int current,int scc[]) {
		scc[v]=current;
		int cn=1;
		Iterator<Integer> it=rlist.get(v).iterator();
		while(it.hasNext()) {
			int e=it.next();
			if(scc[e]==0)
				cn+=dfs2(e,rlist,current,scc);
		}
		return cn;
	}
	public static int dfs3(int v,ArrayList<ArrayList<Integer>> list,boolean [] visited,int count[]) {
		int cn=count[v];
		if(count[v]>1) isCycle=true;
		visited[v]=true;
		Iterator<Integer> it=list.get(v).iterator();
		while(it.hasNext()) {
			int e=it.next();
			if(!visited[e]) {
				cn+=dfs3(e,list,visited,count);
			}
		}
		return cn;
	}*/
	static class InputReader {
		 
		private InputStream stream;
		private byte[] buf = new byte[8192];
		private int curChar;
		private int snumChars;
		private SpaceCharFilter filter;
 
		public InputReader(InputStream stream) {
			this.stream = stream;
		}
 
		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}
 
		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
 
			int res = 0;
 
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
 
			return res * sgn;
		}
		
		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
 
		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}
}
