#include <bits/stdc++.h>
using namespace std;
template <class T, class L>
inline bool smax(T &x, L y) {
  return x < y ? (x = y, true) : false;
}
template <class T, class L>
inline bool smin(T &x, L y) {
  return x > y ? (x = y, true) : false;
}
constexpr int MAXN = 1e6 + 15;
int a[MAXN], b[MAXN];
map<int, vector<int>> add, pos;
multiset<int> st;
int ans;
int n;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    add[a[i]].push_back(i);
    b[i] = a[i];
  }
  sort(b, b + n);
  for (int i = 0; i < n; i++) {
    pos[b[i]].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == b[i]) {
      ans++;
      continue;
    }
    int x = add[b[i]].back();
    for (int j = i; j <= x; j++) {
      st.insert(a[j]);
      if (a[j] == b[j]) {
        st.erase(st.find(a[j]));
        continue;
      }
      if (st.count(b[j])) {
        st.erase(st.find(b[j]));
        continue;
      }
      smax(x, add[b[j]].back());
    }
    st.clear();
    i = x;
    ans++;
  }
  return cout << ans << '\n', false;
}
