#P1103. Taking Photo

    ID: 104 远端评测题 2000ms 128MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>湖南省第十三届大学生计算机程序设计竞赛(HNCPC2017)

Taking Photo

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.

6
5 2 5 2 1 5
7
1 5 1 2 7 2 2
6
2 1 1 4 3 3
3
3
0