http://codeforces.com/contest/1008/problems
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MAXN=1e5+10;
const int INF=0x3f3f3f3f;
int a[MAXN];
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
sort(a+1,a+1+n);
int j=1,cnt=0;
for(int i=1;i<=n;i++)
{
if(a[i]>a[j])
{
cnt++;
j++;
}
}
cout<<cnt<<endl;
//cout << "Hello world!" << endl;
return 0;
}