#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 9;
const int M = 1e3 + 9;
const int INF = 1e9 + 9;
int a[N];
map<int, int> mp;
int main() {
  ios::sync_with_stdio(0);
  int n, first, second, ans = 0, prev = 0;
  cin >> n;
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  for (auto v : mp) {
    ans += min(prev, v.second);
    prev -= min(prev, v.second);
    prev += v.second;
  }
  cout << ans;
  return 0;
}
