#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  long long int i;
  vector<long long int> v(n + 1, 0);
  for (i = 1; i <= n; i++) cin >> v[i];
  long long int minn = 1000000007, index = 0;
  for (long long int i = n; i >= 1; i--) {
    if (v[i] > minn) {
      index = i;
      break;
    }
    minn = min(minn, v[i]);
  }
  cout << index << "\n";
  return 0;
}
