import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto ps = readln.split.to!(int[]);
    auto qs = new bool[](N+1);
    int r, last = 1;
    foreach_reverse (p; ps) {
        qs[p] = true;
        if (p == last) ++r;
        while (last <= N && qs[last]) ++last;
    }
    writeln(r);
}