CF1208B Uniqueness

题目描述

给你一个n(1≤n≤2000)个数的序列A1,A2...An(1≤Ai≤1e9),我们要删除一个子串,使得数列中余下的数两两不重复,问删除字串的最短长度。

输入格式

第一行一个整数n; 第二行n个整数,表示A数列。

输出格式

一行一个整数,为最小删除长度。

说明/提示

In the first example all the elements are already distinct, therefore no subsegment needs to be removed. In the second example you can remove the subsegment from index $ 2 $ to $ 3 $ . In the third example you can remove the subsegments from index $ 1 $ to $ 2 $ , or from index $ 2 $ to $ 3 $ , or from index $ 3 $ to $ 4 $ .