n = int(input())
p = list(map(int, input().split()))
q = [0] * (n + 2)
c = 0
ans = 0
for i in range(n):
    if p[i] == i + 1:
        q[i + 1] = 1
for i in range(1, n + 2):
    if q[i] == 1 and q[i - 1] == 0:
        c = 1
    elif q[i] == 1 and q[i - 1] == 1:
        c += 1
    elif q[i] == 0 and q[i - 1] == 1:
        ans += (c + 1) // 2
print(ans)
print(q)