#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  multiset<int> s;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    v.push_back(x);
    s.insert(x);
  }
  sort(v.begin(), v.end());
  int cnt = 0;
  for (int x : v) {
    auto ed = s.end();
    ed--;
    if (*ed <= x) break;
    auto it = s.lower_bound(x + 1);
    cnt++;
    s.erase(it);
  }
  printf("%d\n", cnt);
  return 0;
}
