#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, temp, s = 0, x, y, i[100000], j[100000];
  cin >> a;
  for (b = 0; b < a; b++) {
    j[b] = 0;
  }
  for (b = 0; b < a; b++) {
    cin >> i[b];
    if (i[b] == b + 1) {
      j[b] = 1;
    }
  }
  for (y = 1; y < 2;) {
    for (b = 0; b < a; b++) {
      if (j[b] == 1) {
        s++;
        if (j[b - 1] == 1) {
          temp = i[b - 1];
          i[b - 1] = i[b];
          i[b] = temp;
        } else {
          if (i[b + 1] != b + 1) {
            temp = i[b + 1];
            i[b + 1] = i[b];
            i[b] = temp;
          } else {
            temp = i[b - 1];
            i[b - 1] = i[b];
            i[b] = temp;
          }
        }
      }
      for (c = 0; c < a; c++) {
        if (i[c] == c + 1) {
          j[c] = 1;
        }
        cout << j[c] << " ";
      }
      cout << endl;
    }
    x = 0;
    for (b = 0; b < a; b++) {
      if (j[b] == 1) {
        continue;
      }
    }
    cout << s;
    return 0;
  }
  return 0;
}
