#include <iostream>
using namespace std;
int a[200006];
// int bm(int d, int index){
// int temp = d;
// for(int i = index; i <= temp; i++){
// if(a[i] > temp){
// temp = a[i];
// }
// }
// }
int main() {
int n; cin>>n;
for(int i = 1; i <= n; i++){
cin>>a[i];
}
int cnt = 0;
int t = 1;
while(t <= n){
if(a[t] == t){
cnt++;
t++;
}else
if(a[t] != t){
int temp = a[t];
for(int j = t; j <= temp; j++){
if(a[j] > temp){
temp = a[j];
}
}
t = temp;
}
}
cout<<cnt;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IGFbMjAwMDA2XTsKCi8vIGludCBibShpbnQgZCwgaW50IGluZGV4KXsKLy8gCWludCB0ZW1wID0gZDsKLy8gCWZvcihpbnQgaSA9IGluZGV4OyBpIDw9IHRlbXA7IGkrKyl7Ci8vIAkJaWYoYVtpXSA+IHRlbXApewovLyAJCQl0ZW1wID0gYVtpXTsKLy8gCQl9Ci8vIAl9Ci8vIH0KCmludCBtYWluKCkgewoJaW50IG47IGNpbj4+bjsKCWZvcihpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKXsKCQljaW4+PmFbaV07Cgl9CglpbnQgY250ID0gMDsKCWludCB0ID0gMTsKCXdoaWxlKHQgPD0gbil7CgkJaWYoYVt0XSA9PSB0KXsKCQkJY250Kys7CgkJCXQrKzsKCQl9ZWxzZQoJCWlmKGFbdF0gIT0gdCl7CgkJCWludCB0ZW1wID0gYVt0XTsKCQkJZm9yKGludCBqID0gdDsgaiA8PSB0ZW1wOyBqKyspewoJCQkJaWYoYVtqXSA+IHRlbXApewoJCQkJCXRlbXAgPSBhW2pdOwoJCQkJfQoJCQl9CgkJCXQgPSB0ZW1wOwoJCX0KCX0KCWNvdXQ8PGNudDsKCXJldHVybiAwOwp9