Since Christmas is over, and Arstin's neighbour, Justharva, is back home from vacation, Arstin needs to remove all of his Christmas trees from Justharva's front yard. There are Christmas trees in a row. The Christmas tree is labelled with a number . Some trees will have the same label.
In one move, Arstin can remove up to as many Christmas trees which all have the same label and are contiguous. If Arstin removes the to Christmas trees, the Christmas tree will now be adjacent to the Christmas tree.
Arstin wants to remove all of his Christmas trees in the least amount of moves. Can you write a program to help him determine the least amount of moves it will take him to remove all of his Christmas trees?
Constraints
For of the points, .
For of the points, .
Input Specification
The first line contains the integer , the number of Christmas trees.
The next line contains space separated integers, the labels of the Christmas trees.
Output Specification
Output the minimum amount of moves it would take Arstin to remove all of his Christmas trees.
Sample Input 1
5
1 2 3 2 1
Sample Output 1
3
Explanation for Sample Output 1
If Arstin were first to remove the tree labelled with a '3', the two trees labelled with '2' will become adjacent and Arstin can move them both in 1 move. Then the two trees labelled with '1', will become adjacent and Arstin can remove them with one move. There will be a total of 3 moves.
Sample Input 2
5
1 1 1 1 1
Sample Output 2
1
Comments
What is without constraints?
This comment is hidden due to too much negative feedback. Show it anyway.