n boys are standing in a line. Many of them are brothers from the same families. We may ask some people to leave the line so that the brothers of each family end up standing next to one another. However, the people in the line are fiercely loyal to their brothers: if any single person is removed, all of his brothers take offense and leave the line as well.
Determine the maximum number of families that can remain in the line after such changes, in such a way that the brothers of every remaining family stand next to each other. Note: an only child counts as a full family on its own.
The first line contains one integer n (1≤n≤1,000,000), the number of people standing in the line. The second line contains n integers l1,l2,…,ln (1≤li≤1,000,000) separated by single spaces, where li is the number of the family that the i-th boy belongs to.
Print a single integer equal to the maximum number of families that can remain in the line.