include[HTML_REMOVED]
using namespace std;
typedef pair[HTML_REMOVED] PII;
const int N = 200010;
int n;
PII a[N];
int main()
{
cin >> n;
for (int i = 0; i < n; i )
{
cin >> a[i].first;
a[i].second = i;
}
sort(a, a + n);
int res = 1;
for (int i = 0, last = n + 1, dir = -1; i < n; )
{
int j = i;
while (j < n && a[j].first == a[i].first) j ;
int minx = a[i].second, maxx = a[j - 1].second;
if (dir == -1)
{
if (last > maxx) last = minx;
else dir = 1, last = maxx;
}
else
{
if (last < minx) last = maxx;
else
{
res ++ ;
last = minx;
dir = -1;
}
}
i = j;
}
cout << res << endl;
return 0;
}