Description

Medium

The Runic Stone Arrangement

An archaeologist discovered ancient runic stones, each with a magical frequency value. The stones must be arranged in a row such that no two adjacent stones have the same frequency.

Given an array of stone frequencies, find the length of the longest arrangement where no two adjacent stones share the same frequency. You can pick any subset of stones and arrange them in any order.

Note: You cannot use a stone more than once.

Input Format

The first line contains an integer n, the number of stones. The second line contains n space-separated integers representing the frequency of each stone.

Output Format

Print a single integer representing the maximum length of a valid arrangement.

Examples

Example 1

Input
5 1 1 1 2 2
Output
4
ExplanationArrange as [1,2,1,2]. We use 2 stones with freq 1 and 2 stones with freq 2.

Example 2

Input
4 1 1 1 1
Output
1
ExplanationAll stones have the same frequency, so we can only use 1.

Constraints

1 ≤ n ≤ 100000

1 ≤ frequency[i] ≤ 10^9

Code

Login
Error

Case 1

Case 2

Input
5 1 1 1 2 2
Output
No output
Expected
5