#include <bits/stdc++.h>
const int N = 100200;
using namespace std;
struct node {
  int id, x;
  node() {}
  node(int a, int b) {
    id = a;
    x = b;
  }
  bool operator<(const node a) const { return x < a.x; }
};
int n, a[N], b[N];
vector<node> v;
vector<int> v2;
multiset<node> s;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
    v.push_back(node(i, a[i]));
    s.insert(node(i, a[i]));
  }
  int ans = 0;
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); ++i) {
    node t = v[i];
    set<node>::iterator it = s.upper_bound(t);
    if (it != s.end()) {
      b[t.id] = (*it).x;
      ++ans;
      s.erase(it);
    }
  }
  printf("%d\n", ans);
  return 0;
}
