SOLVE
LATER
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.
Input Format:
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.
Output Format:
Single integers -- minimal cost of elimination of all balls.
Constraints:
\(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.