Home => ProblemSet => 2.12-29:删除回文子序列
Problem1691--2.12-29:删除回文子序列

1691: 2.12-29:删除回文子序列

Time Limit: 1 Sec  Memory Limit: 128 MB  Submit: 0  Solved: 0
[ Submit ] [ Status ] [ Creator: ][ 参考程序 ]

Description

我们有一个连续的序列,每个序列上面都是一个数字c[i],每次我们都能够消灭一个连续的回文子序列,消灭之后左右会合并,成为一个新序列,问最少需要多少次才能够把整个序列消灭掉。回文就是从左到有从右到左读到的序列都是一样的。

Input

第一行一个正整数n
第二行n个非负整数,空格分隔

Output

一行一个正整数

Sample Input Copy

7
1 4 4 2 3 2 1

Sample Output Copy

2

HINT



1 <= n <= 1000

Source/Category