#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a;
  map<int, int> m;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    m[a]++;
  }
  while (1) {
    int minn = 9999;
    for (map<int, int>::iterator itr = m.begin(); itr != m.end(); itr++) {
      if ((*itr).second != 0 && minn > (*itr).second) {
        minn = (*itr).second;
      }
    }
    if (minn == 9999) break;
    int cnt = 0;
    for (map<int, int>::iterator itr = m.begin(); itr != m.end(); itr++) {
      if ((*itr).second != 0) {
        (*itr).second -= minn;
        cnt++;
      }
    }
    ans += (cnt - 1) * minn;
  }
  cout << ans;
}
