MCIPC Contest 2 P2 - Icicles
View as PDFAs part of your mandatory forty hours of community service, you have been tasked with getting rid of some rather unsightly icicles outside of Martingrove.
There are  icicles that you were tasked with destroying, with the 
 icicle having a length of 
. When you destroy an icicle its length is set to 
. After careful examination, you realize that the icicles can be spared for aesthetic reasons if they are symmetrical. That is, a sequence of 
 icicles is considered symmetrical if the 
 icicle from the left has the same length as the 
 icicle from the right.
What is the minimum number of icicles that you must destroy?
Constraints
Input Specification
The first line contains the integer .
The second line contains  integers, where the 
 integer represents the length of the 
 icicle.
Output Specification
Output a single integer, the minimum number of icicles needed to be destroyed.
Sample Input
5
3 2 1 4 3
Sample Output
2
Explanation for Sample
By destroying the  and 
 icicles, the icicles are now symmetrical.
Comments