Algorithm


A. 123-sequence
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

There is a given sequence of integers a1, a2, ..., an, where every number is from 1 to 3 inclusively. You have to replace the minimum number of numbers in it so that all the numbers in the sequence are equal to each other.

Input

The first line contains an integer n (1 ≤ n ≤ 106). The second line contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 3).

Output

Print the minimum number of replacements needed to be performed to make all the numbers in the sequence equal.

Examples
input
Copy
9
1 3 2 2 2 1 1 2 3
output
Copy
5
Note

In the example all the numbers equal to 1 and 3 should be replaced by 2.



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <cstdio>
#include <iostream>
#include <algorithm>

int main(){

    long count[4] = {0};

    long n; scanf("%ld", &n);
    for(long p = 0; p < n; p++){int temp; scanf("%d", &temp); ++count[temp];}
    std::sort(count, count + 4);
    printf("%ld\n", count[1] + count[2]);

    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
9
1 3 2 2 2 1 1 2 3

Output

x
+
cmd
5
Advertisements

Demonstration


Codeforces Solution-A. 123-sequence-Solution in C, C++, Java, Python

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+