#include <bits/stdc++.h>
int main() {
  int n, i;
  scanf("%d", &n);
  int arr[n + 5];
  int max = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
    if (arr[i] > max) max = arr[i];
  }
  int count = 0;
  for (i = 1; i <= n; i++) {
    if (arr[i] != max && arr[i] > arr[i + 1]) count++;
  }
  printf("%d\n", count);
  return 0;
}
