#include <bits/stdc++.h>
using namespace std;
const long long N = 5e4 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;
int n;
map<int, int> used;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    used[x]++;
  }
  int res = 1;
  for (auto x : used) {
    res = max(res, x.second);
  }
  cout << (n - res) << "\n";
}
