Russian version of the problem can be read here.

As you probably know, cats usually fight with dogs.

There are N doghouses in a backyard. For simplicity, we consider the backyard as a plane, and the doghouses as points on the plane. All doghouses are numbered from 1 to N. The i-th doghouse is located at point (i, Y[i]). (Note that this means that there are no two doghouses with the same x-coordinate.)

Cats are about to build some rectangular fence, parallel to the axis. If some doghouse is located at the perimeter of the fence, it should be removed. Your task it to find the maximum possible number of doghouses that may be removed after choosing arbitrary fence sizes and location. Please note that the area covered by the fence may be equal to 0.

Input format

The first line of the input contains the single integer N - the number of doghouses. The next line contains N space-separated integers that are Y-coordinates of the corresponding doghouse.

Output format

In the only line of the output print the maximum number of doghouses that may be removed.

Constraints

1 ≤ N ≤ 1,000, 0 ≤ Y[i] ≤ 1,000.

SAMPLE INPUT
5
2 3 4 1 1

SAMPLE OUTPUT
4
def main():
	n=int(raw_input())
	Y=map(int,raw_input().split())
	y={}
	i=0
	while(i<len(Y)):
		if Y[i] in y:
			y.update({Y[i]:[y[Y[i]][0],i,y[Y[i]][2]+1]})
		else:
			y.update({Y[i]:[i,i,1]})
		i+=1
	if n==1:
		print "1"
	else:
		ans=0
		flag=0
		for key1 in y:
			g=key1
			for key2 in y:
				if key2!=key1:
					flag=1
					x=min(key1,key2)
					z=max(key1,key2)
					tempans=y[key1][2]+y[key2][2]
					left=min(y[key1][0],y[key2][0])
					right=max(y[key1][1],y[key2][1])
					i=0
					while(i<left):
						if Y[i]>x and Y[i]<z:
							tempans+=1
							break
						i+=1
					i=right+1
					while(i<n):
						if Y[i]>x and Y[i]<z:
							tempans+=1
							break
						i+=1
					if tempans>ans:
						ans=tempans
		if flag==0:
			print y[g][2]
		else:
			print ans
main()