#include <bits/stdc++.h>
using namespace std;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= 998244353;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 998244353;
    a = a * a % 998244353;
  }
  return res;
}
class C {
 public:
  void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    vector<long long> a(n), copy(n);
    for (int i = (0); i < (n); ++i) {
      cin >> a[i];
      copy[i] = a[i];
    }
    sort((a).begin(), (a).end());
    sort((copy).begin(), (copy).end());
    int i = 0, j = 0;
    for (; i < n && j < n; ++i) {
      if (copy[j] < a[i]) {
        copy[j] = a[i];
        ++j;
      }
    }
    long long res = 0;
    for (i = 0; i < n && i <= j; i++) {
      if (copy[i] > a[i]) ++res;
    }
    cout << res << "\n";
  }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  C solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
