#include <bits/stdc++.h>
using namespace std;
int num[100050];
int main() {
  int n;
  while (cin >> n) {
    for (int i = 0; i < n; i++) scanf("%d", &num[i]);
    stable_sort(num, num + n);
    int ans = 0;
    int k = 0;
    for (int i = 1; i < n; i++) {
      if (num[i] > num[k]) {
        ans++;
        k++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
