#include <bits/stdc++.h>
using namespace std;
int a[100100], ans;
map<int, int> mp;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    auto second = mp.upper_bound(a[i]);
    if (second == mp.end()) continue;
    ans++;
    int ny = second->first;
    mp[ny]--;
    if (mp[ny] == 0) mp.erase(ny);
  }
  cout << ans;
}
