#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  long long int j = 0, cnt = 0;
  cin >> t;
  vector<int> vt(1005);
  vector<int> ct;
  for (int i = 1; i <= t; i++) {
    int x;
    cin >> x;
    vt[x]++;
  }
  for (int i = 1; i <= 1001; i++) {
    if (vt[i]) {
      ct.push_back(vt[i]);
      cnt++;
      j++;
    }
  }
  sort(ct.begin(), ct.end());
  int count = 0, k = 0;
  for (int i = 0; i < j - 1; i++) {
    ct[i] -= (k);
    count = count + ct[i] * (cnt - 1);
    k += ct[i];
    cnt -= 1;
  }
  cout << count << endl;
  return 0;
}
