You have a sequence of balls. Every ball has a color. You can eliminate any single ball and pay one pound. Also you can eliminate any two neighboring balls which have the same colors for no cost.
Find minimal amount you need to spend to eliminate all balls.
First line contains single integer $$n$$ -- number of balls.
Second line contains $$n$$ space-separated integers $$a_1,a_2,\dots,a_n$$ -- colors of balls.
Single integers -- minimal cost of elimination of all balls.
$$1 \leqslant n \leqslant 500.$$
$$1 \leqslant a_i \leqslant 100.$$
You can eliminate second ball for one pound. After that, you can eliminate remaining two balls for no price.