Big Bazar
Mr. Kate has joined as a manager in Big Bazar at Venice Mall Greater Noida. After joining the store, Mr. Kate wants to make the store attractive as all the items are arranged randomly.
In the store there are n products in a row and ith item has color ci. To make the store attractive Mr. Kate instructed his team to arrange all the products in a row by considering that the same color products are next to each other. In a single operation, a person can take one product from any position and move that product to the extreme right position (in particular row). You help Mr. Kate by knowing that what is the minimum number of operations required to make the row attractive?
Input
The first line contains one integer n (1 ≤ n ≤ 5105)* — the number of products.
The second line contains n integers c1, c2, …, cn — the product colors.
Output
Single integer stating the minimum number of operations to make the row attractive.
Sample Input:
5
1 2 2 1 3
Sample Output:
2
Input:
5
1 2 2 1 1
Output:
1