#include <bits/stdc++.h>
using namespace std;
class Sample {
 private:
  int a;
  static int b;

 public:
  static int c;
  Sample(int x) {
    a = x;
    b += x;
  }
  static void disp(Sample s) { cout << "a = " << s.a << ", b = " << b << endl; }
};
class Point {
 private:
  int x;
  const int y;

 public:
  Point(int a = 0, int b = 0) : x(a), y(b) {}
  int fun() {
    x = 5;
    return x + y;
  }
  int fun() const { return x + y; }
};
long long ksm(long long a, long long b, long long c) {
  long long r = 1;
  a = a % c;
  while (b) {
    if (b & 1) r = (r * a) % c;
    a = (a * a) % c;
    b >>= 1;
  }
  return r;
}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[n + 1];
  a[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  int cnt = 1;
  for (int i = 2; i <= n; i++) {
    if (a[i] != a[i - 1]) {
      cnt++;
    }
  }
  int m = n, ans = 0;
  for (int i = n; i >= 1; i--) {
    int now = a[i];
    while (a[m] >= a[i]) m--;
    if (m == 0) {
      cout << ans;
      return 0;
    } else {
      m--;
      ans++;
    }
  }
  return 0;
}
