#include <iostream>
using namespace std;
int main()
{
    int n , Big , big , chichi;
    cin >> n;
    big = 0;
    Big = 0;
    chichi = 0;
    int Alfa[n] , Omega[n];

    for ( int i = 0 ; i < n ; i ++ )
    {
        cin >> Alfa[i];
    }

    for ( int i = 0 ; i < n ; i ++ )
    {
        Omega[i] = 0;
    }

    for ( int i = 0 ; i < n ; i ++ )
    {
        for ( int x = 0 ; x < n ; x ++ )
        {
            if ( Alfa[i] > Alfa[x] )
            {
                Big = i;
                Omega[Big] = 1;
            }

            else if ( Alfa[i] < Alfa[x] )
            {
                Big = x;
                Omega[Big] = 1;
            }
        }
    }

    for ( int i = 0 ; i < n ; i ++ )
    {
        for ( int x = 0 ; x < n ; x ++ )
        {
            if ( Alfa[i] > Alfa[x] && i != Big )
            {
                big = i;
                Omega[big] = 1;
            }

            else if ( Alfa[i] < Alfa[x] && i != Big )
            {
                Big = x;
                Omega[Big] = 1;
            }
        }
    }

    int i = 0;
    int z = 0;
    if ( big - Big > 0 )
    {
        i = Big;
        z = big;
    }

    else 
    {
        i = big;
        z = Big;
    }

    while ( i < n )
    {
        if ( Omega[i + 1] == 1 )
        {
            chichi ++;
        }

        if ( i == n - 1 )
        {
            cout << chichi;
        }

        i ++;
    }

    return 0;
}