count = int(input());
data = [];
for i in range(count):
    data.append(int(input()));
gaps = [1];
for i in range(99):
    next_gap = 3 * gaps[-1] + 1;
    if count > next_gap:
        gaps.append(next_gap);
    else:
        break;
gaps.reverse();

def shell_sort(data, gaps):
    o = 0;
    for gap in gaps:
        for g in range(gap):
            o += insert_sort(data, gap, g);
    return o;

def insert_sort(data, gap, g):
    o = 0;
    count = len(data);
    for i in range(g + gap, count, gap):
        n = data[i];
        j = i - gap;
        while j >= 0:
            if data[j] > n:
                o += 1;
                data[j + gap] = data[j];
                j -= gap;
            else:
                break;
        data[j + gap] = n;
    return o;

o = shell_sort(data, gaps);

print(len(gaps));
print(" ".join(str(n) for n in gaps));
print(o);
print("\n".join(str(n) for n in data)); count = int(input()) count int(input()) int input() input data = [] data [] for i in range(count):
    data.append(int(input())); i range(count) range count data.append(int(input())) data.append data append int(input()) int input() input gaps = [1] gaps [1] 1 for i in range(99):
    next_gap = 3 * gaps[-1] + 1;
    if count > next_gap:
        gaps.append(next_gap);
    else:
        break; i range(99) range 99 next_gap = 3 * gaps[-1] + 1 next_gap 3 * gaps[-1] + 1 3 * gaps[-1] 3 gaps[-1] gaps -1 1 if count > next_gap:
        gaps.append(next_gap);
    else:
        break; count > next_gap count next_gap gaps.append(next_gap) gaps.append gaps append next_gap break gaps.reverse() gaps.reverse gaps reverse def shell_sort(data, gaps):
    o = 0;
    for gap in gaps:
        for g in range(gap):
            o += insert_sort(data, gap, g);
    return o; shell_sort o = 0 o 0 for gap in gaps:
        for g in range(gap):
            o += insert_sort(data, gap, g);
     gap gaps for g in range(gap):
            o += insert_sort(data, gap, g);
     g range(gap) range gap o += insert_sort(data, gap, g) o insert_sort(data, gap, g) insert_sort data gap g return o o data data gaps gaps def insert_sort(data, gap, g):
    o = 0;
    count = len(data);
    for i in range(g + gap, count, gap):
        n = data[i];
        j = i - gap;
        while j >= 0:
            if data[j] > n:
                o += 1;
                data[j + gap] = data[j];
                j -= gap;
            else:
                break;
        data[j + gap] = n;
    return o; insert_sort o = 0 o 0 count = len(data) count len(data) len data for i in range(g + gap, count, gap):
        n = data[i];
        j = i - gap;
        while j >= 0:
            if data[j] > n:
                o += 1;
                data[j + gap] = data[j];
                j -= gap;
            else:
                break;
        data[j + gap] = n;
     i range(g + gap, count, gap) range g + gap g gap count gap n = data[i] n data[i] data i j = i - gap j i - gap i gap while j >= 0:
            if data[j] > n:
                o += 1;
                data[j + gap] = data[j];
                j -= gap;
            else:
                break;
         j >= 0 j 0 if data[j] > n:
                o += 1;
                data[j + gap] = data[j];
                j -= gap;
            else:
                break;
         data[j] > n data[j] data j n o += 1 o 1 data[j + gap] = data[j] data[j + gap] data j + gap j gap data[j] data j j -= gap j gap break data[j + gap] = n data[j + gap] data j + gap j gap n return o o data data gap gap g g o = shell_sort(data, gaps) o shell_sort(data, gaps) shell_sort data gaps print(len(gaps)) print len(gaps) len gaps print(" ".join(str(n) for n in gaps)) print " ".join(str(n) for n in gaps) " ".join " " join str(n) str n print(o) print o print("\n".join(str(n) for n in data)) print "\n".join(str(n) for n in data) "\n".join "\n" join str(n) str n def insert_sort(data, gap, g):
    o = 0;
    count = len(data);
    for i in range(g + gap, count, gap):
        n = data[i];
        j = i - gap;
        while j >= 0:
            if data[j] > n:
                o += 1;
                data[j + gap] = data[j];
                j -= gap;
            else:
                break;
        data[j + gap] = n;
    return o; def insert_sort(data, gap, g):
    o = 0;
    count = len(data);
    for i in range(g + gap, count, gap):
        n = data[i];
        j = i - gap;
        while j >= 0:
            if data[j] > n:
                o += 1;
                data[j + gap] = data[j];
                j -= gap;
            else:
                break;
        data[j + gap] = n;
    return o; insert_sort count = int(input()) int(input()) count gaps = [1] [1] gaps def shell_sort(data, gaps):
    o = 0;
    for gap in gaps:
        for g in range(gap):
            o += insert_sort(data, gap, g);
    return o; def shell_sort(data, gaps):
    o = 0;
    for gap in gaps:
        for g in range(gap):
            o += insert_sort(data, gap, g);
    return o; shell_sort o = shell_sort(data, gaps) shell_sort(data, gaps) o next_gap = 3 * gaps[-1] + 1 3 * gaps[-1] + 1 next_gap data = [] [] data
count = int(input());
data = [];
for i in range(count):
    data.append(int(input()));
gaps = [1];
for i in range(99):
    next_gap = 3 * gaps[-1] + 1;
    if count > next_gap:
        gaps.append(next_gap);
    else:
        break;
gaps.reverse();

def shell_sort(data, gaps):
    o = 0;
    for gap in gaps:
        for g in range(gap):
            o += insert_sort(data, gap, g);
    return o;

def insert_sort(data, gap, g):
    o = 0;
    count = len(data);
    for i in range(g + gap, count, gap):
        n = data[i];
        j = i - gap;
        while j >= 0:
            if data[j] > n:
                o += 1;
                data[j + gap] = data[j];
                j -= gap;
            else:
                break;
        data[j + gap] = n;
    return o;

o = shell_sort(data, gaps);

print(len(gaps));
print(" ".join(str(n) for n in gaps));
print(o);
print("\n".join(str(n) for n in data));
