#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7f7f7f7f;
const int MAXN = 1e3 + 111;
int num[MAXN];
int main() {
  int n, x, up = 0;
  cin >> n;
  memset(num, 0, sizeof num);
  for (int i = 0; i < n; ++i) {
    cin >> x;
    ++num[x];
    up = max(up, num[x]);
  }
  int ans = 0;
  for (int i = 0; i < up; ++i) {
    int cnt = 0;
    for (int i = 1; i <= 1000; ++i) {
      if (num[i]) {
        ++cnt;
        --num[i];
      }
    }
    ans += cnt - 1;
  }
  cout << ans << endl;
  return 0;
}
