#include <bits/stdc++.h>
using namespace std;
int n;
vector<long long> v;
void input() {
  cin >> n;
  long long a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
}
void solve() {
  input();
  int c = 0, i = 0, j = 1;
  while (i < n && j < n) {
    if (v[j] > v[i]) {
      c++;
      i++;
      j++;
    } else
      j++;
  }
  cout << c << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
