//basic queue
/*
#include <stdio.h>
#define size 5
int queue[size],rear=-1,front=-1;
void enqueue(int data)
{
// full?
if(rear+1!=size)
{
queue[++rear]=data;
}
else
{
printf("queue is full!!\n");
}
}
int dequeue()
{
// empty?
if(front!=rear)
{
return queue[++front];
}
else
{
printf("queue is empty!\n");
}
}
void view()
{
for(int i=0;i<size;i++)
{
printf("%d ",queue[i]);
}
printf("\n");
}
*/
//circular queue
/*
#include <stdio.h>
#define size 6
int queue[size],rear=0,front=0;
void enqueue(int data)
{
// full?
if((rear+1)%size!=front)//
{
rear=(rear+1)%size;
queue[rear]=data;
}
else
{
printf("queue is full!!\n");
}
}
int dequeue()
{
int data;
// empty?
if(front!=rear)
{
front=(front+1)%size;
data=queue[front];
queue[front]=0;
return data;
}
else
{
printf("queue is empty!\n");
return 0;
}
}
void view()
{
printf("------------------------\n");
for(int i=0;i<size;i++)
{
printf("%2d ",i);
}
printf("\n");
for(int i=0;i<size;i++)
{
printf("%2d ",queue[i]);
}
printf("\n");printf("------------------------\n");
}
int main()
{
//mooyaho~~~
int n, c,w;
while(1)
{
printf("1.enq 2.deq 3.front,rear >>");
scanf("%d",&n);
if(n==1)
{
printf("enq data is >>");
scanf("%d",&c);
enqueue(c);
view();
}
else if(n==2)
{
w=dequeue();
if(w!=0) printf("deq data is %d\n",w);
view();
}
else if(n==3)
{
printf("front = %d rear = %d\n",front,rear);
}
else{
break;
}
}
return 0;
}
*/
#include <stdio.h>
int stack[80000],top=-1;
void push(int data)
{
stack[++top]=data;
}
int pop()
{
return stack[top--];
}
int main()
{
int i,j,cnt=0,a,b;
scanf("%d",&a);
for(i=1;i<=a;i++)
{
scanf("%d",&b);
push(b);
}
for(i=0;i<a;i++)
{
if(i==a-1)
{
printf("%d",cnt);
return 0;
}
if(stack[i]>stack[i+1])
{
cnt++;
for(j=i+2;j<a;j++)
{
if(stack[i]>stack[j])
{
cnt++;
}
else
{
break;
}
}
}
}
printf("%d",cnt);
}