#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
void solve() {
  int n;
  cin >> n;
  int arr[n];
  int brr[n];
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  int i = 0;
  while (i < n && arr[i] == arr[0]) {
    i++;
  }
  int j = 0;
  int cnt = 0;
  while (i < n) {
    if (arr[j] < arr[i]) {
      cnt++;
      j++;
    }
    i++;
  }
  cout << cnt;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}
