CSG-CPC
Online Judge

1103 : Taking Photo

         Time Limit: 2 Sec     Memory Limit: 128 MB     Submitted: 26     Solved: 2    

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

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

Hint

Author

Staginner