cswork / OAOpen practice workspace

AmazonOA #287

Min Operation

Estimated MediumJudge-ready

Topics (AI-labelled)HashingGreedy

In each operation, either ship any single item, or ship any two items from different locations together. The two items need not be adjacent; the remaining items keep their relative order, but that does not restrict the next free choice. Find the minimum number of operations to ship all items.

Input

The first line contains n and the second line contains locations. The original length is written as n in the body and as m in the constraints and starter; it is unified as n: 1≤n≤100000, 1≤locations[i]≤10^9.

Output

Output a single integer, the answer.

Example 1

Input:

4
1 1 1 2

Output:

3

Example 2

Input:

3
1 2 3

Output:

2

Example 3

Input:

2
5 5

Output:

2

Example notes

The answers are 3, 2 and 2 respectively. In the first example only one 2 can be paired with a 1, and the other two 1s must ship alone.

Editorial

Loading solution…