#include <bits/stdc++.h>
const long long MOD = (long long)1e9 + 7;
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long a[n], b[n];
  map<long long, int> S, E;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  for (int i = 0; i < n; i++) {
    if (S[b[i]] == 0 && b[0] == b[i])
      S[b[i]] = 0;
    else if (S[b[i]] == 0)
      S[b[i]] = i;
    E[b[i]] = max(E[b[i]], i);
  }
  map<long long, int> Cnt;
  int at = 1;
  int MXend = -1;
  for (int r = 0; r < n; r++) {
    MXend = max(MXend, S[a[r]] + Cnt[a[r]]);
    Cnt[a[r]]++;
    if (MXend == r) {
      at++;
    }
  }
  cout << at - 1 << "\n";
}
