Processing math: 100%
Compressing array - MarisaOJ: Marisa Online Judge

Compressing array

Time limit: 1000 ms
Memory limit: 256 MB

Given an array a with n elements, you can perform the following operation an infinite number of times: Choose an index 1≤i≤n−1 such that ai=ai+1, delete the two elements ai and ai+1, and replace them with an element with the value ai+1. Find the minimum possible length of the array a.

Input

  • The first line contains a natural number n≤500.
  • The next line contains n natural numbers of the array a, each ≤1000.

Output

  • Print the minimum possible length of the array a.

Sample Test

Input:

7
3 3 4 4 4 3 3

Output:

2