Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/ruby
from __future__ import print_function
import sys
if sys.version_info[0]>=3: raw_input=input

def insertionSort(a, n, g):
	global cnt
	for i in range(g,n):
		v = a[i]
		j = i - g
		while j >= 0 and a[j] > v:
			a[j+g] = a[j]
			j = j - g
			cnt+=1
			a[j+g] = v

def shellSort(a, n):
	global cnt
	cnt = 0
	g = []
	h = 1
	while h <= n:
		g.append(h)
		h = 3*h+1
	g.reverse()
	m = len(g)
	print(m)
	print(' '.join(map(str,g)))
	for i in range(m):
		insertionSort(a, n, g[i])

a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a,len(a))
print(cnt)
map(print,a)

Fixed submission:
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input

def insertionSort(a,g):
	global cnt
	for i in range(g,len(a)):
		v = a[i]
		j = i - g
		while j >= 0 and a[j] > v:
			a[j+g] = a[j]
			j = j - g
			cnt+=1
			a[j+g] = v

def shellSort(a):
	global cnt
	cnt = 0
	g = []
	h = 1
	while h <= len(a):
		g.append(h)
		h = 3*h+1
	g.reverse()
	m = len(g)
	print(m)
	print(' '.join(map(str,g)))
	for i in range(m):
		insertionSort(a,g[i])

a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/ruby
import sys
if sys.version_info[0]>=3: raw_input=input

def insertionSort(a, n, g):
	global cnt
	for i in range(g,n):
		v = a[i]
		j = i - g
		while j >= 0 and a[j] > v:
			a[j+g] = a[j]
			j = j - g
			cnt+=1
			a[j+g] = v

def shellSort(a, n):
	global cnt
	cnt = 0
	g = []
	h = 1
	while h <= n:
		g.append(h)
		h = 3*h+1
	g.reverse()
	m = len(g)
	print(m)
	print(' '.join(map(str,g)))
	for i in range(m):
		insertionSort(a, n, g[i])

a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a,len(a))
print(cnt)
for e in a: print(e)

Fixed submission:
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input

def insertionSort(a,g):
	global cnt
	for i in range(g,len(a)):
		v = a[i]
		j = i - g
		while j >= 0 and a[j] > v:
			a[j+g] = a[j]
			j = j - g
			cnt+=1
			a[j+g] = v

def shellSort(a):
	global cnt
	cnt = 0
	g = []
	h = 1
	while h <= len(a):
		g.append(h)
		h = 3*h+1
	g.reverse()
	m = len(g)
	print(m)
	print(' '.join(map(str,g)))
	for i in range(m):
		insertionSort(a,g[i])

a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/ruby
import sys
if sys.version_info[0]>=3: raw_input=input

def insertionSort(a, n, g):
	global cnt
	for i in range(g,n):
		v = a[i]
		j = i - g
		while j >= 0 and a[j] > v:
			a[j+g] = a[j]
			j = j - g
			cnt+=1
			a[j+g] = v

def shellSort(a, n):
	global cnt
	cnt = 0
	g = []
	h = 1
	while h <= n:
		g.append(h)
		h = 3*h+1
	g.reverse()
	m = len(g)
	print(m)
	print(' '.join(map(str,g)))
	for i in range(m):
		insertionSort(a, n, g[i])

a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a,len(a))
print(cnt)
for e in a: print(e)

Fixed submission:
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input

def insertionSort(a,g):
	global cnt
	for i in range(g,len(a)):
		v = a[i]
		j = i - g
		while j >= 0 and a[j] > v:
			a[j+g] = a[j]
			j = j - g
			cnt+=1
			a[j+g] = v

def shellSort(a):
	global cnt
	cnt = 0
	g = []
	h = 1
	while h <= len(a):
		g.append(h)
		h = 3*h+1
	g.reverse()
	m = len(g)
	print(m)
	print(' '.join(map(str,g)))
	for i in range(m):
		insertionSort(a,g[i])

a=[int(raw_input()) for i in range(int(raw_input()))]
shellSort(a)
print(cnt)
for e in a: print(e)