Problem I
Imperfection
Mei has an array
Mei wants to delete some elements from
Can you help Mei find the minimum cost to delete elements such that the resulting array is perfect?
Input
The first line of input contains one integer
The second line of the input contains
The third line of the input contains
Output
Output one line containing one integer denoting the minimum cost.
Sample Input 1 | Sample Output 1 |
---|---|
4 5 3 3 3 3 2 2 2 |
3 |
Sample Input 2 | Sample Output 2 |
---|---|
15 3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 8 6 4 7 5 1 3 4 9 8 5 4 1 2 2 |
34 |