//#include <stdio.h>
//#include <stdlib.h>
//
//int main()
//{
// printf("Hello world!\n");
// return 0;
//}
//#include <stdio.h>
//
//#define SIZE 300
//
//int stack[SIZE] = {0};
//int top=0;
//int number = 0;
//
//void mult(){
// stack[top-2] = stack[top-2] * stack[top-1];
// top--;
//}
//
//void pushh(int k){
// stack[top-1] = (stack[top-1]*10) + k;
//}
//
//void push(int k){
// stack[top]=k;
// top++;
//}
//
//void add(){
// stack[top-2] = stack[top-2] + stack[top-1];
// top--;
//}
//
//void sub(){
// stack[top-2] = stack[top-2] - stack[top-1];
// top--;
//}
//
//int main(){
// int i, j, l;
// char str[1000]={0};
// gets(str);
// for(i=0;i<strlen(str);i++){
// if(str[i]=='+'){
// add();
// j=0;
// }
// else if(str[i]=='-'){
// sub();
// j=0;
// }
// else if(str[i]=='*'){
// mult();
// j=0;
// }
// else if(str[i]==' '){
// j=0;
// }
// else{
// j++;
// if(j<=1){
// push(str[i]-'0');
// }
// if(j>=2){
// pushh(str[i]-'0');
// }
// }
//// printf("[%d]",stack[top-1]);
// }
// printf("%d",stack[top-1]);
//}
//#include<stdio.h>
//
//int main() {
// char input[10000] = {0};
// int n=0, i;
//
// gets(input);
// for(i=0; i<strlen(input); i++) {
// if(input[i]==' ') {
// if(n != 0) {
// printf("data is %d\n", n);
// n = 0;
// }
// }
// else {
// n *= 10;
// n += (input[i]-'0');
// }
// }
// printf("%d", n);
//
//
//}
#include <stdio.h>
#define SIZE 10000
int stack[SIZE] = {0};
int top = 0;
int push(int k)
{
int l=0, i, j;
stack[top]=k;
j=k;
for(i=top; i>=0; i--)
{
if(stack[i]>stack[top])
{
if(stack[i]>j)
{
l++;
j=stack[i];
}
}
}
top++;
return l;
}
int main()
{
int n, i, j, l =0;
scanf("%d",&n);
for(i=0; i<n; i++)
{
scanf("%d", &j);
l=l+push(j);
}
printf("%d",l);
}