#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 7;
int a[N];
pair<int, int> ar[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    ar[i] = make_pair(a[i], i);
  }
  sort(a + 1, a + n + 1);
  int ans = 0;
  int cur = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i] > a[cur]) {
      cur++;
    }
  }
  cout << cur - 1;
}
