CF1208B Uniqueness

题目描述

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

输入格式

第一行一个整数 $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 $ .