1103 : Taking Photo

时间限制Time Limit 2 Sec 内存限制Memory Limit 128 MB 提交次数Submitted 26 Times 通过次数Solved 2 Times 标准评测Standard Judge

题目描述Description

There are some people from a company sitting in a line and waiting to take a group photo. For some reason, the people coming from the same department want to sit together, i.e., sit in some continuous seats. Note that the seats cannot be moved, but they can change seats with others. Now, they need your help to figure out the minimum number of people involved in changing seats.

输入格式Input

There will be at most 200 test cases. Each case begins with one integer n(3 ≤ n ≤ 30), the number of the people. The next line contains n integers xi(1 ≤ xi ≤ n), describing the department identifiers of the people from left to right. People with the same identifier belong to the same department.

输出格式Output

For each test case, print the minimum number of people involved in changing seats.

样例Sample

出题Author

Staginner