#include <stdio.h>

int cnt, m = 2, G[] = {3, 1};

void insertionSort(int A[], int n, int g) {
  int i;
  for (i = g; i < n; i += g) {
    int v = A[i], j = i - g;
    while ((j >= 0) && (A[j] > v)) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n) {
  cnt = 0;
  int i;
  for (i = 0; i < m; i++) {
    insertionSort(A, n, G[i]);
  }
}

int main() {
  int n;
  scanf("%d", &n);
  int A[n], i;
  for (i = 0; i < n; i++) {
    scanf("%d", A + i);
  }
  shellSort(A, n);
  printf("%d\n", m);
  for (i = 0; i < n; i++) {
    printf("%d", A[i]);
    if (i == n - 1) {
      printf("\n");
    } else {
      printf(" ");
    }
  }
  printf("%d", cnt);
}