#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x, j, i, c = 0;
  cin >> n;
  vector<long long> v;
  vector<long long> v1;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  j = n - 2;
  i = n - 1;
  while (j >= 0) {
    if (v[i] > v[j]) {
      c++;
      i--;
    }
    j--;
  }
  cout << c;
}
