#include <bits/stdc++.h>
#define N 100000
using namespace std;
int n,a[N+2],d;
int main()
{
    freopen("CAU4.INP","r",stdin);
    freopen("CAU4.OUT","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<n;i++)
        for(int j=i+1;j<=n;j++)
            if(i<j&&a[i]<a[j]&&a[i]>0&&a[j]>0)
            {
                d++;
                a[i]=a[j]=0;
            }
    cout<<d;
    return 0;
}
