def has_match_with_index(ls, left_inx):
    for inx, item in enumerate(ls[left_inx:]):
        if inx + left_inx == item - 1:
            return True
    return False

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

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

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

if __name__ == "__main__":
    main()
