#CCBCHBAHAI0000081. Equalize the Array

    ID: 999 Loại: Thông thường 2000ms 256MiB Tried: 0 Đã chấp nhận: 0 Độ khó: 1 Đăng bởi: Nhãn>Programming language basicsStatic arraysIteration techniquesImplementation techniquesWorking with numbers

Equalize the Array

Equalize the Array

Source: HackerRank

Version: Phuoc Hung OJ Extended

Problem

Given an integer array of length nn, delete the minimum number of elements so that all remaining elements are equal. Let

f(v)=∣{i∣0≤i<n, ai=v}∣.f(v)=|\{i\mid0\le i<n,\ a_i=v\}|.

Keeping a value vv requires n−f(v)n-f(v) deletions, hence the answer is

D=n−max⁡vf(v).D=n-\max_v f(v).

Compute DD.

Input

The first line contains nn. The second line contains nn integers aia_i.

Output

Print DD, the minimum number of deletions.

Subtask

Subtask 1 (20 points): 1≤n≤101\le n\le10, 1≤ai≤1001\le a_i\le100.

Subtask 2 (30 points): 1≤n≤501\le n\le50, 1≤ai≤1001\le a_i\le100.

Subtask 3 (50 points): 1≤n≤1001\le n\le100, 1≤ai≤1001\le a_i\le100.

Example

Input

5
3 3 2 1 3

Output

2

Explanation

The output follows directly from the mathematical definition above.