MCIPC Contest 2 P2 - Icicles

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

As 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 N icicles that you were tasked with destroying, with the ith icicle having a length of Li. When you destroy an icicle its length is set to 0. After careful examination, you realize that the icicles can be spared for aesthetic reasons if they are symmetrical. That is, a sequence of N icicles is considered symmetrical if the ith icicle from the left has the same length as the ith icicle from the right.

What is the minimum number of icicles that you must destroy?

Constraints

1N,Li106

Input Specification

The first line contains the integer N.

The second line contains N integers, where the ith integer represents the length of the ith icicle.

Output Specification

Output a single integer, the minimum number of icicles needed to be destroyed.

Sample Input

Copy
5
3 2 1 4 3

Sample Output

Copy
2

Explanation for Sample

By destroying the 2nd and 4th icicles, the icicles are now symmetrical.


Comments

There are no comments at the moment.