#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
vector<int> fr;
int v[100100];
int main() {
  int n;
  scanf("%d ", &n);
  int mf = 0;
  for (int i = 0; i < n; i++) {
    int t;
    scanf("%d ", &t);
    v[i] = t;
    m[t]++;
    mf = max(mf, m[t]);
  }
  sort(begin(v), end(v));
  fr.assign(mf + 2, 0);
  for (auto& it : m) {
    fr[it.second - 1]++;
  }
  int rs = 0;
  int ma = 0;
  for (int i = fr.size() - 2; i >= 0; i--) {
    fr[i] = fr[i + 1] + fr[i];
  }
  for (int i = 0; i < fr.size(); i++) {
    rs += fr[i];
    ma = max(ma, rs - i - 1);
  }
  printf("%d\n", ma);
}
