#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, count, i;
  cin >> n;
  int arr[n];
  count = n;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (i = 0; i < n; i++) {
    if (arr[i] <= arr[i + 1] && (i + 1) != n) {
      count--;
    } else if (arr[0] == arr[n - 1]) {
      count--;
    }
  }
  cout << count << endl;
  return 0;
}
