using System;

class TEST
{
    public static void Main()
    {
        int num = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
        int[] people = new int[num];

        for (int i = 0; i < num; i++)
            people[i] = int.Parse(str[i]);

        int sabun = 0;
        while (true)
        {
            for (int i = 1; i < num; i++)
            {
                if (people[i] - people[i - 1] > 0)
                {
                    sabun++;
                    continue;
                }
            }
            break;
        }

        Console.WriteLine(sabun);

    }
}