use v5.18;

chomp (my $n = <STDIN>);
chomp (my @p = split / /, <STDIN>);
my @q;
for my $i (0..$n-1) {
  $q[$i] = $i + 1 - $p[$i];
}
my ($ans, $cnt) = (0, 1);
my $sp = 0;
while ($ans != $cnt) {
  $cnt = $ans;
  for my $i ($sp..$n-2) {
    if ($q[$i] == 0) {
      if ($q[$i+1] != 1) {
        ($q[$i], $q[$i+1]) = ($q[$i+1]-1, $q[$i]+1);
        $ans++;
      } else {
        $sp = $i;
      }
    }
  }
}
say $ans;