def count_match_with_index(ls):
    cnt = 0
    for inx, item in enumerate(ls):
        if inx == item - 1:
            cnt += 1
    return cnt

def swap(ls):
    left_inx  = get_left_inx(ls) 
    ls[left_inx], ls[left_inx + 1] = ls[left_inx + 1], ls[left_inx]
    return ls

def get_left_inx(ls):
    for inx, item in enumerate(ls):
        if inx == item - 1:
            return inx
    return 0

def main():
    n = int(input())
    ls = list(map(int, input().split()))
    cnt = 0
    while (count_match_with_index(ls) > 0):
        ls = swap(ls)
        cnt += 1
    print(cnt)

if __name__ == "__main__":
    main()
