def swap(a, b):
    tmp = a
    a = b
    b = tmp
    return a, b


def solve(): # 072D- Derangement
    N = int(input())
    p = list(map(int, input().split(" ")))
    p.insert(0, 1)
    cnt = 0

    for i in range(1, N+1):
        if i == p[i]:
            p[i], p[i+1] = swap(p[i], p[i+1])
            cnt += 1
            print(p, i)
        elif i == N and i == p[i]:
            p[i-1], p[i] = swap(p[i-1], p[i])
            cnt += 1
            print(p)
        else:
            pass

    print(cnt)
    
    
solve()