#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int arr[n];
  unordered_map<int, int> m;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    m[arr[i]]++;
  }
  int maxVal = 0;
  for (auto x : m) {
    maxVal = max(maxVal, x.second);
  }
  cout << n - maxVal;
}
int main() { solve(); }
