#include <bits/stdc++.h>
using namespace std;
using ii = pair<long long int, long long int>;
class prioritize {
 public:
  bool operator()(ii &p1, ii &p2) { return p1.first < p2.first; }
};
bool checker(long long int x, long long int n, long long int s) {
  if (x <= s - n)
    return true;
  else
    return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  long long int arr[n];
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  long long int p1 = 0, p2 = 0, cnt = 0;
  while (p1 < n && p2 < n) {
    if (arr[p1] == arr[p2]) {
      p2++;
      continue;
    }
    if (arr[p2] > arr[p1]) {
      cnt++;
      p1++;
      p2++;
    } else
      p2++;
  }
  cout << cnt << "\n";
}
