#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

//============================================================================
#define pred(x) ((x)-1)
#define succ(x) ((x)+1)
//============================================================================
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
struct node {
    long num; struct node *left, *right;
};
//----------------------------------------------------------------------------
typedef struct node NODE;
//----------------------------------------------------------------------------
long Value,Cnt;
//----------------------------------------------------------------------------
char *my_alloc(int n)
{
    char *p;

    p = malloc(n);
    if (p == NULL){
        printf("Not enough memory\n"); exit(1);
    }
    return p;
}
//----------------------------------------------------------------------------
long countnode(NODE *p)
{
    long cnt=1;

    if (p==NULL)
        return 0;
    if (p->left==NULL && p->right==NULL)
       return cnt;
    if (p->left!=NULL)
        cnt+=countnode(p->left);
    if (p->right!=NULL)
        cnt+=countnode(p->right);
    return cnt;
}
//----------------------------------------------------------------------------
NODE *addnode(NODE *p)
{
    char *my_alloc();

    if (p == NULL){
        p = (NODE *)my_alloc(sizeof(NODE));
        p->num=Value;
        p->left = p->right = NULL;
    }else{
        if (Value< p->num){
            Cnt++;
            Cnt+=countnode(p->right);
            p->left = addnode(p->left);
        }else if (Value> p->num)
            p->right = addnode(p->right);
    }
    return p;
}
//----------------------------------------------------------------------------
void deltree(NODE **pp)
{
    if (*pp != NULL){
        deltree(&(*pp)->left); deltree(&(*pp)->right);
        free(*pp);
        *pp=NULL;
    }
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void input(FILE *file)
{
    long n,i; NODE *root;

    fscanf(file, "%ld", &n);
    for (i=Cnt=0, root=NULL; i<n; i++){
        fscanf(file, "%ld", &Value);
        root=addnode(root);
    }
    printf("%ld\n", Cnt);
    deltree(&root);
}
//============================================================================
#ifndef DESKTOP
int main()
{
    input(stdin);
    return 0;
}
#endif