#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e6 + 10;
const int inf = (int)2e9;
vector<int> v;
int arr[N], n;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    v.push_back(arr[i]);
  }
  sort(v.begin(), v.end());
  int answer = 0;
  for (int i = 0; i < n; i++) {
    if (lower_bound(v.begin(), v.end(), arr[i] + 1) != v.end()) {
      answer += 1;
      v.erase(lower_bound(v.begin(), v.end(), arr[i] + 1));
    }
  }
  printf("%d\n", answer);
  return 0;
}
