A browsing session visits n items in order, each tagged with an integer category id. Let U be the number of distinct categories that appear anywhere in the session. Find the length of the shortest contiguous run of visits that contains at least one item from every one of those U categories.
Input format
Line 1: an integer n.
Line 2: n space-separated integers, the category ids in visit order.
Output format
A single integer: the length of the shortest contiguous window that contains all U distinct categories.
Constraints
- 1 ≤ n ≤ 100000
- 1 ≤ each category id ≤ 1000000000