The first line of input contains N.
The next line contains N integers in the range 1…N indicating the color of each cell in Picowso's latest 1-dimensional painting.
Output the minimum number of brush strokes needed to copy the painting.
In this example, Moonet may paint the array as follows. We denote an unpainted cell by 0.
Initially, the entire array is unpainted:0 0 0 0 0 0 0 0 0 0Moonet paints the first nine cells with color 11:1 1 1 1 1 1 1 1 1 0Moonet paints an interval with color 22:1 2 2 2 2 2 2 2 1 0Moonet paints an interval with color 33:1 2 3 3 3 3 3 2 1 0Moonet paints an interval with color 44:1 2 3 4 4 4 3 2 1 0Moonet paints a single cell with color 11:1 2 3 4 1 4 3 2 1 0Moonet paints the last cell with color 66:1 2 3 4 1 4 3 2 1 6Note that during the first brush stroke, Moonet could have painted the tenth cell with color 11 in addition to the first nine cells without affecting the final state of the array.
In test cases 2-4, only colors 1 and 2 appear in the painting.
In test cases 5-10, the color of the i-th cell is in the rangefor each
.
Test cases 11-20 satisfy no additional constraints.Problem credits: Brian Dean and Benjamin Qi