#include <bits/stdc++.h>   using namespace std;   template <typename T>   T gcd(T a, T b) {     while (b) {       T c = a % b;       a = b;       b = c;     }     return a;   }   template <typename T>   T lcm(T a, T b) {     assert(a / gcd(a, b) <= numeric_limits<T>::max() / b);     return a * (b / gcd(a, b));   }   class out {    public:     template <typename T>     out &operator()(const T &t) {       cout << t <<    ;       return *this;     }     template <typename T1, typename T2>     out &operator()(const pair<T1, T2> &t) {       cout <<  (  << t.first <<  ,  << t.second <<  )  <<    ;       return *this;     }   };   template <typename iter>   void print(iter beg, iter end) {     for_each(beg, end, out());     cout << endl;   }   long n;   long h[100000];   long g[100000];   long r = 0;   void algo() {     for (long i = 1; i < n; ++i) {       g[i] = max(g[i - 1], h[i - 1]);     }     long t = h[n - 1];     for (long i = n - 1; i >= 0; --i) {       t = min(t, h[i]);       if (t >= g[i]) {         ++r;       }     }   }   int main() {     cin >> n;     for (long i = 0; i < n; ++i) {       cin >> h[i];     }     algo();     cout << r;     return 0;   }   