#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int mi = N + 1;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    int P;
    cin >> P;
    ans += P <= mi;
    mi = min(mi, P);
  }
  cout << ans << "\n";
  return 0;
}

#include <bits/stdc++.h>

using namespace std; 
 
#define int long long
#define M 1000000007
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int val=1;
	int cnt=0;
	int ans[n+1]={0};
	for(int i=n-1;i>=0;i--){
		if(a[i]==val){
			cnt++;
			ans[val]=1;
			while(ans[val]==1){
				val++;
			}
		}
		ans[a[i]]=1;
	}
	cout << cnt << endl;
}
