You are given an array of n integers. Find the length of the longest contiguous subarray that contains at most two distinct values.
A subarray is a run of consecutive elements. A subarray of one element (or of several equal elements) always qualifies, so the answer is at least 1.
Input format
Line 1: an integer n.
Line 2: n space-separated integers, the array.
Output format
A single integer: the length of the longest such subarray.
Constraints
- 1 <= n <= 100000
- -1000000000 <= each value <= 1000000000