You are given a deck of n cards numbered from 1 to n (not necessarily in this order in the deck). You have to sort the deck by repeating the following operation. 

  * Choose 2 ≤ k ≤ n and split the deck in k nonempty contiguous parts D_1, D_2,..., D_k (D_1 contains the first |D_1| cards of the deck, D_2 contains the following |D_2| cards and so on). Then reverse the order of the parts, transforming the deck into D_k, D_{k-1}, ..., D_2, D_1 (so, the first |D_k| cards of the new deck are D_k, the following |D_{k-1}| cards are D_{k-1} and so on). The internal order of each packet of cards D_i is unchanged by the operation. 



You have to obtain a sorted deck (i.e., a deck where the first card is 1, the second is 2 and so on) performing at most n operations. It can be proven that it is always possible to sort the deck performing at most n operations.

Examples of operation: The following are three examples of valid operations (on three decks with different sizes). 

  * If the deck is [3 6 2 1 4 5 7] (so 3 is the first card and 7 is the last card), we may apply the operation with k=4 and D_1=[3 6], D_2=[2 1 4], D_3=[5], D_4=[7]. Doing so, the deck becomes [7 5 2 1 4 3 6]. 
  * If the deck is [3 1 2], we may apply the operation with k=3 and D_1=[3], D_2=[1], D_3=[2]. Doing so, the deck becomes [2 1 3]. 
  * If the deck is [5 1 2 4 3 6], we may apply the operation with k=2 and D_1=[5 1], D_2=[2 4 3 6]. Doing so, the deck becomes [2 4 3 6 5 1]. 

Input

The first line of the input contains one integer n (1≤ n≤ 52) — the number of cards in the deck.

The second line contains n integers c_1, c_2, ..., c_n — the cards in the deck. The first card is c_1, the second is c_2 and so on.

It is guaranteed that for all i=1,...,n there is exactly one j∈\{1,...,n\} such that c_j = i.

Output

On the first line, print the number q of operations you perform (it must hold 0≤ q≤ n).

Then, print q lines, each describing one operation.

To describe an operation, print on a single line the number k of parts you are going to split the deck in, followed by the size of the k parts: |D_1|, |D_2|, ... , |D_k|. 

It must hold 2≤ k≤ n, and |D_i|≥ 1 for all i=1,...,k, and |D_1|+|D_2|+⋅⋅⋅ + |D_k| = n.

It can be proven that it is always possible to sort the deck performing at most n operations. If there are several ways to sort the deck you can output any of them.

Examples

Input


4
3 1 2 4


Output


2
3 1 2 1
2 1 3


Input


6
6 5 4 3 2 1


Output


1
6 1 1 1 1 1 1


Input


1
1


Output


0

Note

Explanation of the first testcase: Initially the deck is [3 1 2 4]. 

  * The first operation splits the deck as [(3) (1 2) (4)] and then transforms it into [4 1 2 3]. 
  * The second operation splits the deck as [(4) (1 2 3)] and then transforms it into [1 2 3 4]. 

Explanation of the second testcase: Initially the deck is [6 5 4 3 2 1]. 

  * The first (and only) operation splits the deck as [(6) (5) (4) (3) (2) (1)] and then transforms it into [1 2 3 4 5 6].

Source: codeforces | Difficulty: HARD
Tags: Implementation

Constructive algorithms


Solutions:
from sys import stdin, stdout
n = int(stdin.readline())
c = [int(x) for x in stdin.readline().split()]
ops = []
turn = True
for x in range(n - 1):
	newC = []
	newC2 = []
	op = []
	ind = c.index(x + 1)
	if turn:
		if ind != 0:
			op.append(ind)
		op.append(n - x - ind)
		op += [1] * x
	else:
		op += [1] * x
		op.append(ind - x + 1)
		if ind + 1 != n:
			op.append(n - ind - 1)
	ops.append([len(op)] + op)
	cur = 0
	for y in op:
		newC.append(c[cur:cur + y])
		cur += y
	for x in newC[::-1]:
		newC2 += x
	c = newC2
	turn = not turn
out = []
for x in ops:
	if x[0] != 1:
		out.append(' '.join([str(y) for y in x]))
if c[0] != 1:
	out.append(' '.join([str(n)] + ['1' for x in range(n)]))
print(len(out))
for x in out:
	print(x)


import math
import sys
from collections import deque
from typing import Deque, Dict, List, Optional, Set, Tuple

def data():
	return sys.stdin.buffer.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(res):
	sys.stdout.write(' '.join(map(str, res)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')

def input_lst():
	return mdata()

def print_out(res):
	outl(res)

def main():
	n = int(data())
	a = mdata()
	a_pos = [0] * n
	for i in range(n):
		a[i] -= 1
		a_pos[a[i]] = i
	res = []
	d = True
	for i in range(n - 1):
		res_str = []
		for j in range(i):
			res_str.append(1)
		a_i = a_pos[i]
		if a_i - i + 1 > 0:
			res_str.append(a_i - i + 1)
		if n - a_i - 1 > 0:
			res_str.append(n - a_i - 1)
		if not d:
			res_str.reverse()
		d = not d
		if len(res_str) > 1:
			res.append(res_str)
		for j in range(i, n):
			pos = a_pos[j]
			pos -= i
			pos = n - i - pos
			pos += a_i - i + (n - i)
			pos %= n - i
			pos += i
			a_pos[j] = pos
	if not d:
		res.append([1] * n)
	print(len(res))
	for res_str in res:
		print(str(len(res_str)) + ' ' + ' '.join(map(str, res_str)))
main()


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
a = list(map(int, input().split()))
ans = []
if a[n - 1] == 1:
	parity = 1
else:
	parity = 0
for i in range(n - 1):
	if parity % 2 == 0:
		for j in range(n):
			if a[j] == i + 1 and j != i:
				ans.append([])
				for k in range(i):
					ans[-1].append(str(1))
				ans[-1].append(str(j - i + 1))
				if n - j - 1 > 0:
					ans[-1].append(str(n - j - 1))
				ans[-1].reverse()
				t = len(ans[-1])
				ans[-1].append(str(t))
				ans[-1].reverse()
				b = []
				for k in range(j + 1, n):
					b.append(a[k])
				for k in range(i, j + 1):
					b.append(a[k])
				for k in range(i - 1, -1, -1):
					b.append(k + 1)
				a = b.copy()
				parity += 1
				break
	else:
		for j in range(n):
			if a[j] == i + 1 and j != n - i - 1:
				ans.append([])
				if j > 0:
					ans[-1].append(str(j))
				if n - j - 1 > 0:
					ans[-1].append(str(n - j - i))
				for k in range(i):
					ans[-1].append(str(1))
				ans[-1].reverse()
				t = len(ans[-1])
				ans[-1].append(str(t))
				ans[-1].reverse()
				b = []
				for k in range(i):
					b.append(k + 1)
				for k in range(j, n - i):
					b.append(a[k])
				for k in range(j):
					b.append(a[k])
				a = b.copy()
				parity += 1
				break
if a[0] != 1:
	ans.append([str(n)])
	for i in range(n):
		ans[-1].append(str(1))
print(len(ans))
for i in ans:
	print(' '.join(i))


n = int(input())
a = list(map(int, input().split()))
cnt = 0
ans = []
for i in range(n):
	l = []
	if i % 2 == 1:
		if i == n - 1:
			continue
		for j in range(i):
			l.append(1)
		for j in range(n):
			if a[j] == i + 1:
				l.append(j - i + 1)
				l.append(n - j - 1)
		j = l[-2] + i
		a = a[j:] + a[i:j] + list(reversed(a[:i]))
	else:
		for j in range(n):
			if a[j] == i + 1:
				l.append(j)
				l.append(n - j - i)
		j = l[-2]
		for k in range(i):
			l.append(1)
		if i == 0:
			a = a[j:] + a[:j]
		else:
			a = list(reversed(a[-i:])) + a[j:-i] + a[:j]
	l = [x for x in l if x != 0]
	k = len(l)
	if k >= 2:
		ans.append(l)
		cnt += 1
print(cnt)
for row in ans:
	print(len(row), *row)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write('\n'.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = float('inf')
mod = 10 ** 9 + 7
n = int(data())
c = mdata()
ans = []
for i in range(n - 1):
	for j in range(n):
		if c[j] == i + 1:
			break
	if i % 2 == 0:
		if j == 0:
			if i == 0:
				continue
			else:
				ans.append([i + 1, n - i - j] + [1] * i)
				c = c[n - 1:n - i - 1:-1] + c[j:n - i] + c[:j]
				continue
		ans.append([i + 2, j, n - i - j] + [1] * i)
		c = c[n - 1:n - i - 1:-1] + c[j:n - i] + c[:j]
	else:
		if j == n - 1:
			ans.append([i + 1] + [1] * i + [j + 1 - i])
			c = c[j + 1:n] + c[i:j + 1] + c[:i][::-1]
			continue
		ans.append([i + 2] + [1] * i + [j + 1 - i, n - j - 1])
		c = c[j + 1:n] + c[i:j + 1] + c[:i][::-1]
if n % 2 == 1 and n > 1:
	ans.append([n] + [1] * n)
for i in range(len(ans)):
	ans[i] = ' '.join(map(str, ans[i]))
out(len(ans))
if ans:
	outl(ans)


import os, sys
from io import BytesIO, IOBase

def main():
	n = int(input())
	card = list(map(int, input().split()))
	if n == 1 or card == sorted(card):
		print(0)
		exit()
	x = card.index(1)
	if x != n - 1:
		op = [[2, x + 1, n - x - 1]]
		card = card[x + 1:] + card[:x + 1]
	else:
		op = []
	en = 1
	for i in range(2, n + 1):
		x = card.index(i)
		if en:
			if x == n - i:
				continue
			op.append([])
			if x:
				op[-1].append(x)
			if n - x - i + 1:
				op[-1].append(n - x - i + 1)
			op[-1].extend([1] * (i - 1))
			op[-1] = [len(op[-1])] + op[-1]
			card = list(range(1, i + 1)) + card[x + 1:n - i + 1] + card[:x]
		else:
			if x == i - 1:
				continue
			op.append([])
			op[-1].extend([1] * (i - 1))
			if x - i + 2:
				op[-1].append(x - i + 2)
			if n - 1 - x:
				op[-1].append(n - 1 - x)
			op[-1] = [len(op[-1])] + op[-1]
			card = card[x + 1:] + card[i - 1:x] + list(range(i, 0, -1))
		en ^= 1
	if card == sorted(card, reverse=1):
		op.append([n] + [1] * n)
	print(len(op))
	for i in op:
		print(*i)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def solve(n, xs):
	if xs == sorted(xs):
		return []
	n_idx = [0] * (n + 1)
	for i in range(n):
		n_idx[xs[i]] = i
	pos = None
	for i in range(n - 1):
		if xs[i] + 1 == xs[i + 1]:
			pos = i
			break
	if pos is None:
		pos = 1
		while n_idx[pos + 1] >= n_idx[pos]:
			pos += 1
		a = n_idx[pos + 1]
		b = n_idx[pos]
		op = [a, b - a, 1, n - b - 1]
		op = [o for o in op if o > 0]
		ys = xs[b + 1:] + xs[b:b + 1] + xs[a:b] + xs[:a]
		return [op] + solve(n, ys)
	ys = xs.copy()
	for j in range(xs[pos] + 1, n + 1):
		ys[n_idx[j]] = j - 1
	del ys[pos]
	ops = []
	for o in solve(n - 1, ys):
		p = []
		t = 0
		new_pos = 0
		for x in o:
			if t <= pos < t + x:
				new_pos = pos - t
				x += 1
			else:
				new_pos += x
			p.append(x)
			t += x
		pos = new_pos
		ops.append(p)
	return ops
ops = solve(int(input()), list(map(int, input().split())))
print(len(ops))
for op in ops:
	print(len(op), *op)


n = int(input())
arr = list(map(int, input().split()))
o = []
q = 0
while arr != sorted(arr):
	j = 0
	for i in range(len(arr)):
		if arr[i] != i + 1:
			j = i
			break
	k = arr.index(arr[j] - 1)
	l = 0
	for i in range(j, k):
		if arr[i] + 1 != arr[i + 1]:
			l = i
			break
	l += 1
	arr = arr[k + 1:] + arr[l:k + 1] + arr[j:l] + arr[0:j]
	o.append([j - 0, l - j, k + 1 - l, n - k - 1])
	q += 1
print(q)
for line in o:
	while 0 in line:
		line.remove(0)
	print(len(line), ' '.join(list(map(str, line))))


n = int(input())
l = input().split()
l = [int(ll) for ll in l]

def permutate(l):
	for (i, e1) in enumerate(l):
		if e1 > i + 1:
			break
	else:
		return False
	for j in range(i + 1, n):
		if l[j] == e1 - 1:
			break
	kk = 0
	for k in range(j - 1, i, -1):
		if l[k] == l[k + 1] - 1:
			kk += 1
		else:
			break
	n_parts = []
	parts = []
	if i > 0:
		n_parts.append(i)
		parts.append(l[:i])
	n_parts.append(j - i - kk)
	parts.append(l[i:j - kk])
	n_parts.append(1 + kk)
	parts.append(l[j - kk:j + 1])
	if j < n - 1:
		n_parts.append(n - 1 - j)
		parts.append(l[j + 1:])
	lt = []
	for p in parts[::-1]:
		lt += p
	return (n_parts, lt)
c = 0
strs = []
while True:
	res = permutate(l)
	if not res:
		break
	(n_parts, l) = res
	c += 1
	n_parts = [str(p) for p in n_parts]
	s = str(len(n_parts)) + ' ' + ' '.join(n_parts)
	strs.append(s)
print(c)
for s in strs:
	print(s)


import sys, os
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

def solve_(lst):
	original_lst = [x for x in lst]
	length = len(lst)
	if length == 1 or sorted(lst) == lst:
		return []
	if sorted(lst) == lst[::-1]:
		return [[1] * length]
	res = []
	check = False
	for i in range(1, length + 1):
		ops = []
		idx = lst.index(i)
		ops = [idx] + [length - idx - (i - 1)] + [1] * (i - 1)
		ops = [x for x in ops if x > 0]
		console(ops)
		assert sum(ops) == length
		arr = []
		ptr = 0
		for op in ops:
			arr.append(lst[ptr:ptr + op])
			ptr += op
		arr = arr[::-1]
		brr = []
		for ar in arr:
			brr.extend(ar)
		lst = brr
		lst = lst[::-1]
		console('ops', ops)
		console('arr', arr)
		console('brr', brr)
		console('lst', lst)
		res.append(ops)
	res[1::2] = [ops[::-1] for ops in res[1::2]]
	lst = original_lst
	console(lst)
	res2 = []
	for ops in res:
		if len(ops) == 1:
			continue
		arr = []
		ptr = 0
		for op in ops:
			arr.append(lst[ptr:ptr + op])
			ptr += op
		arr = arr[::-1]
		brr = []
		for ar in arr:
			brr.extend(ar)
		lst = brr
		console('ops', ops)
		console(lst)
		res2.append(ops)
		if lst == sorted(lst):
			console('early escape')
			return res2
	assert lst == sorted(lst)
	return res

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	pass
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def console(*args):
		pass

def solve(*args):
	console('----- solving ------')
	console(*args)
	console('----- ------- ------')
	return solve_(*args)
if True:
	inp = iter(sys.stdin.buffer.readlines())
	input = lambda : next(inp)
else:
	input = sys.stdin.buffer.readline
for case_num in [1]:
	_ = int(input())
	lst = list(map(int, input().split()))
	res = solve(lst)
	print(len(res))
	console(lst, res)
	for row in res:
		print('{} {}'.format(len(row), ' '.join([str(x) for x in row])))


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
arr = list(map(int, input().split()))
num = []
for i in range(n):
	num.append(i + 1)

def index(arr, n):
	ind = [0] * n
	for i in range(n):
		ind[arr[i] - 1] = i
	return ind

def findSwap(ind, arr, n):
	temp = -1
	for i in range(n - 1):
		if ind[i] + 1 != ind[i + 1]:
			if ind[i] > ind[i + 1]:
				num4 = n - ind[i] - 1
				j = arr.index(i + 1) - 1
				s = i
				while j >= 0:
					if arr[j] != s:
						num2 = j + 1 - arr.index(i + 2)
						num3 = n - num4 - (j + 1)
						num1 = arr.index(i + 2)
						break
					j -= 1
					s -= 1
				temp = [num1, num2, num3, num4]
				break
	return temp

def swap(temp, arr, n):
	lis = []
	for i in range(temp[-1]):
		lis.append(arr[sum(temp[:3]) + i])
	for i in range(temp[-2]):
		lis.append(arr[sum(temp[:2]) + i])
	for i in range(temp[-3]):
		lis.append(arr[sum(temp[:1]) + i])
	for i in range(temp[-4]):
		lis.append(arr[i])
	return lis
if n == 1:
	print(0)
elif n == 2:
	if arr == num:
		print(0)
	else:
		print(1)
		print(2, 1, 1)
else:
	q = 0
	ans = []
	while arr != num:
		ind = index(arr, n)
		temp = findSwap(ind, arr, n)
		arr = swap(temp, arr, n)
		lis = [4 - temp.count(0)]
		for i in range(4):
			if temp[i] != 0:
				lis.append(temp[i])
		ans.append(lis)
		q += 1
	print(q)
	for i in range(q):
		print(' '.join((str(x) for x in ans[i])))


from bisect import bisect_left as _bisect_left
import sys as _sys

def main():
	(n,) = _read_ints()
	c = tuple(_read_ints())
	operations = how_to_sort(c)
	print(len(operations))
	for operation in operations:
		print(len(operation), *operation)

def _read_line():
	result = _sys.stdin.readline()
	assert result[-1] == '\n'
	return result[:-1]

def _read_ints():
	return map(int, _read_line().split())

def how_to_sort(sequence):
	n = len(sequence)
	sequence = list(sequence)
	operations = []
	if n <= 1:
		return operations
	if n == 2:
		if sequence[0] > sequence[1]:
			operations.append((1, 1))
		return operations
	if n % 2 != 0:
		i_mid = n // 2
		(left_part, sorted_part, right_part) = (sequence[:i_mid], [sequence[i_mid]], sequence[i_mid + 1:])
	else:
		assert n >= 4
		(i_left_mid, i_right_mid) = (n // 2 - 1, n // 2)
		if sequence[i_left_mid] > sequence[i_right_mid]:
			operations.append((n // 2 - 1, 1, 1, n // 2 - 1))
			sequence = sequence[i_right_mid + 1:] + [sequence[i_right_mid], sequence[i_left_mid]] + sequence[:i_left_mid]
		(left_part, sorted_part, right_part) = (sequence[:i_left_mid], sequence[i_left_mid:i_right_mid + 1], sequence[i_right_mid + 1:])
	assert len(left_part) == len(right_part)
	while len(sorted_part) < n:
		sorted_n = len(sorted_part)
		lx = left_part.pop(-1)
		rx = right_part.pop(0)
		ilx = _bisect_left(sorted_part, lx)
		irx = _bisect_left(sorted_part, rx)
		if lx <= rx:
			operations.append((len(left_part), 1, ilx, len(sorted_part[ilx:irx]), len(sorted_part[irx:]), 1, len(right_part)))
			operations.append((len(right_part), len(sorted_part[irx:]) + 1, len(sorted_part[ilx:irx]), ilx + 1, len(left_part)))
		else:
			(ilx, irx) = (irx, ilx)
			operations.append((len(left_part), ilx + 1, len(sorted_part[ilx:irx]), len(sorted_part[irx:]) + 1, len(right_part)))
			operations.append((len(right_part), len(sorted_part[irx:]), len(sorted_part[ilx:irx]) + 2, ilx, len(left_part)))
		sorted_part.append(lx)
		sorted_part.append(rx)
		sorted_part.sort()
	for (i, operation) in enumerate(operations):
		operation = tuple(filter(lambda x: x != 0, operation))
		operations[i] = operation
	operations = list(filter(lambda operation: len(operation) > 1, operations))
	return operations
main()


n = int(input())
c = [int(x) for x in input().split()]
solved = c.copy()
solved.sort()
ans = []
for i in range(1, n):
	for j in range(1, n):
		a = c.index(j)
		b = c.index(j + 1)
		z = b + 1
		if b > a:
			if a + 1 == b and a == solved:
				break
			continue
		z = b + 1
		s1 = c[:b]
		while z < a and c[z] == c[z - 1] + 1:
			z += 1
		s2 = c[b:z]
		s3 = c[z:a + 1]
		s4 = c[a + 1:]
		c = s4 + s3 + s2 + s1
		ans.append([str(len(x)) for x in [s1, s2, s3, s4] if x])
print(len(ans))
for an in ans:
	print(len(an), ' '.join(an))


n = int(input())
c = [int(i) for i in input().split(' ')]
ans = []
left = 0
right = 0
m = (n + 1) // 2 + 1
target = m - 1
for t in range(n):
	now0 = []
	if n % 2 == 0:
		if t % 2 == 0:
			target = m + t // 2
		else:
			target = 1 + t // 2
	elif t % 2 == 0:
		target = 1 + t // 2
	else:
		target = m + t // 2
	if right == 0:
		loc = c[left:].index(target)
	else:
		loc = c[left:-right].index(target)
	now0.append(left)
	now0.append(loc)
	now0.append(n - left - right - loc)
	now0.append(right)
	now = []
	for i in now0:
		if i > 0:
			now.append(i)
	if t % 2 == 0:
		left += 1
	else:
		right += 1
	if len(now) > 1:
		ans.append([len(now)] + now)
	segs = []
	cur = 0
	for i in now:
		segs.append(c[cur:cur + i])
		cur += i
	c2 = []
	for i in reversed(segs):
		c2 = c2 + i
	for i in range(n):
		c[i] = c2[i]
print(len(ans))
for i in ans:
	print(' '.join([str(j) for j in i]))


n = int(input())
c = [*map(int, input().split())]
if n % 2:
	c = [n + 1 - i for i in c]
q = 0
o = []
for i in range(n):
	j = c.index(i + 1)
	m = [1] * i
	if j - i + 1:
		m.append(j - i + 1)
	m += [1] * (n - 1 - j)
	if i:
		c = c[:i] + c[j:i - 1:-1] + c[j + 1:]
	else:
		c = c[:i] + c[j::-1] + c[j + 1:]
	if len(m) > 1:
		q += 1
		if i % 2:
			m = m[::-1]
		m = [len(m)] + m
		o.append(' '.join(map(str, m)))
print(q)
print('\n'.join(o))


from itertools import chain
ans = []
n = int(input())
c = tuple(map(int, input().split()))
while True:
	c_index = [0] * (n + 1)
	for i in range(n):
		c_index[c[i]] = i
	for ci in range(1, n):
		cj = ci + 1
		i = c_index[ci]
		j = c_index[cj]
		if i > j:
			k = j
			while c[k] + j == c[j] + k:
				k += 1
			ans.append([di for di in (j, k - j, i + 1 - k, n - i - 1) if di])
			c = c[i + 1:] + c[k:i + 1] + c[j:k] + c[:j]
			break
	else:
		break
print(len(ans))
for d in ans:
	print(len(d), *d)


import sys
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
input = sys.stdin.readline
getS = lambda : input().strip()
getN = lambda : int(input())
getList = lambda : list(map(int, input().split()))
getZList = lambda : [int(x) - 1 for x in input().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)

def solve():
	n = getN()
	li = getList()
	ans = []
	while True:
		if sorted(li) == li:
			break
		if li[0] == 1:
			phase = 'start'
		else:
			phase = 'ascend'
		st = []
		tren = []
		tmp = 0
		target = -1
		for ll in li:
			if tren and ll != tren[-1] + 1:
				if phase == 'start':
					phase = 'ascend'
					st.append(tren)
					tren = []
				elif phase == 'ascend':
					target = tren[0] - 1
					st.append(tren)
					tren = []
					phase = 'end'
			if ll == target:
				tren.append(ll)
				st.append(tren)
				tren = []
			else:
				tren.append(ll)
		if tren:
			st.append(tren)
		ans.append([len(x) for x in st])
		st.reverse()
		li = []
		for ss in st:
			li += ss
	print(len(ans))
	for an in ans:
		print(len(an), *an)

def main():
	n = getN()
	for _ in range(n):
		solve()
	return
solve()


from sys import stdin
n = int(stdin.readline())
cards = list((int(x) for x in stdin.readline().split()))

def to_right(minimum, cards):
	idx = cards.index(minimum)
	output = [1] * (n - minimum)
	if idx - n + minimum + 1 != 0:
		output.append(idx - n + minimum + 1)
	if n - idx - 1 != 0:
		output.append(n - idx - 1)
	return (output, cards[idx + 1:] + cards[n - minimum:idx + 1] + (cards[n - minimum - 1::-1] if n - minimum - 1 >= 0 else []))

def to_left(minimum, cards):
	(output, cards) = to_right(minimum, cards[::-1])
	output = output[::-1]
	cards = cards[::-1]
	return (output, cards)
outputs = []
for runs in range(n, 0, -1):
	if runs % 2 == 1:
		(output, cards) = to_right(runs, cards)
	else:
		(output, cards) = to_left(runs, cards)
	if len(output) == 1:
		continue
	outputs.append((len(output), ' '.join((str(x) for x in output))))
print(len(outputs))
for o in outputs:
	print(o[0], o[1])


n = int(input())
arr = list(map(int, input().split()))
n = len(arr)
movesDone = []

def issorted(arr):
	return all((arr[i] <= arr[i + 1] for i in range(len(arr) - 1)))

def apply(sizes):
	movesDone.append(sizes)
	arrs = []
	curr = 0
	for size in sizes:
		currArr = []
		for i in range(curr, curr + size):
			currArr.append(arr[i])
		arrs.append(currArr)
		curr += size
	arrs.reverse()
	result = []
	for currArr in arrs:
		for num in currArr:
			result.append(num)
	return result
for i in range(n):
	if issorted(arr):
		break
	numSorted = i
	currNum = i + 1
	currIndex = arr.index(currNum)
	sizes = []
	if i % 2 == 0:
		if currIndex > 0:
			sizes.append(currIndex)
		if n - numSorted - currIndex > 0:
			sizes.append(n - numSorted - currIndex)
		for _ in range(numSorted):
			sizes.append(1)
	else:
		for _ in range(numSorted):
			sizes.append(1)
		if currIndex + 1 - numSorted > 0:
			sizes.append(currIndex + 1 - numSorted)
		if n - (currIndex + 1) > 0:
			sizes.append(n - (currIndex + 1))
	if len(sizes) > 1:
		arr = apply(sizes)
if not issorted(arr):
	sizes = [1] * n
	arr = apply(sizes)
assert issorted(arr)
assert len(movesDone) <= n
print(len(movesDone))
for move in movesDone:
	print(len(move), ' '.join(map(str, move)))


n = int(input())
l = list(map(int, input().split()))
i = n - 1
s = []
while i > 0:
	i = n - 1
	while i > 0:
		if l[i] != l[i - 1] % n + 1:
			if l[-1] == n:
				f = l.index(1)
			else:
				f = l.index(l[-1] + 1)
			if f == 0:
				s.append([2, i, n - i])
				l = l[i:n] + l[0:i]
			else:
				s.append([3, f, n - f - (n - i), n - i])
				l = l[i:n] + l[f:i] + l[0:f]
			break
		else:
			i -= 1
	if i == 0:
		f = l.index(1)
		if f != 0:
			s.append([2, f, n - f])
print(len(s))
for i in range(len(s)):
	print(*s[i])


def not_sorted(a):
	if a == sorted(a):
		return False
	return True

def apply(op):
	global a
	parts = []
	ind = 0
	for i in op:
		parts.append(a[ind:ind + i])
		ind += i
	parts = parts[::-1]
	a = []
	for i in parts:
		a.extend(i)

def clean(op):
	new = []
	for i in op:
		if i:
			new.append(i)
	if len(new) != 1:
		ans.append([len(new)] + new)

def apply_op(num, right):
	if right:
		loc = a.index(num)
		op = [1] * (n - num)
		op.append(loc - len(op) + 1)
		op.append(n - loc - 1)
	else:
		loc = a.index(num)
		op = [loc]
		op.append(num - loc)
		op.extend([1] * (n - num))
	clean(op)
	apply(op)
n = int(input())
a = list(map(int, input().split()))
num = n
right = 1
ans = []
while num and not_sorted(a):
	apply_op(num, right)
	right = 1 - right
	num -= 1
print(len(ans))
for i in ans:
	print(*i)


import sys, io, os
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(io.IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def solve(T, A_):
	for b in range(2):
		Ans = []
		A = A_.copy()
		while A != list(range(1, T + 1)):
			if len(Ans) > T:
				break
			ans = []
			old = A[0]
			A_new = []
			a_tmp = [A[0]]
			cnt = 1
			for a in A[1:]:
				if (a < old) ^ b:
					ans.append(cnt)
					cnt = 1
					A_new += a_tmp[::-1]
					a_tmp = []
				else:
					cnt += 1
				a_tmp.append(a)
				old = a
			ans.append(cnt)
			A_new += a_tmp[::-1]
			A_new.reverse()
			b ^= 1
			Ans.append(ans)
			A = A_new
		q = len(Ans)
		if q > T:
			continue
		print(q)
		for ans in Ans:
			print(len(ans), *ans)
		break
	else:
		assert False
T = int(input())
A_ = list(map(int, input().split()))
solve(T, A_)


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
ans = []
cand = []
for a in range(1, n):
	flag = 0
	i = A.index(a)
	for j in range(i):
		if A[j] == a + 1:
			flag = 1
			break
	if not flag:
		cand.append(a)
		continue
	else:
		cur = []
		for k in range(j, i):
			if A[k] > A[k + 1]:
				break
		if j:
			cur.append(j)
		cur.append(k - j + 1)
		cur.append(i - k)
		if n - i - 1:
			cur.append(n - i - 1)
		A = A[i + 1:] + A[k + 1:i + 1] + A[j:k + 1] + A[:j]
		ans.append(cur)
while cand:
	cand2 = []
	for a in cand:
		flag = 0
		i = A.index(a)
		for j in range(i):
			if A[j] == a + 1:
				flag = 1
				break
		if not flag:
			cand2.append(a)
			continue
		else:
			cur = []
			for k in range(j, i):
				if A[k] > A[k + 1]:
					break
			if j:
				cur.append(j)
			cur.append(k - j + 1)
			cur.append(i - k)
			if n - i - 1:
				cur.append(n - i - 1)
			A = A[i + 1:] + A[k + 1:i + 1] + A[j:k + 1] + A[:j]
			ans.append(cur)
	cand = cand2
	if A == sorted(range(1, n + 1)):
		break
if not ans:
	print(0)
else:
	print(len(ans))
	for a in ans:
		cur = [len(a)] + a
		print(*cur)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = 1
for _ in range(t):
	n = ip()
	arr = list(inp())
	perm = [i for i in range(1, n + 1)]
	ct = 1
	pt = 0
	sub = [arr[0]]
	ans = []
	while len(sub) != n:
		k = len(sub)
		part = [0] * n
		element = arr[k]
		for i in range(n - k + 1):
			if sorted(list(perm[i:i + k])) == sorted(list(sub)):
				start = i
				end = i + k
				ch = list(perm[i:i + k])
				for i in range(start, end):
					part[i] = 1
				if ch == sub:
					pass
				else:
					temp = list(ch)
					ele = temp.pop(0)
					temp.append(ele)
					if temp == sub:
						part[start] = 2
					else:
						part[end - 1] = 2
				break
		flag = False
		for i in range(start - 1, -1, -1):
			if perm[i] == element:
				flag = True
				break
		if flag:
			for i in range(start - 1, -1, -1):
				if perm[i] == element:
					part[i] = 3
					break
				else:
					part[i] = 3
		else:
			for i in range(end, n):
				if perm[i] == element:
					part[i] = 3
					break
				else:
					part[i] = 3
		sub.append(element)
		prev = None
		ct = 1
		stack = []
		gap = []
		for i in part:
			if len(stack) == 0:
				stack.append(i)
			elif stack[-1] == i:
				stack.append(i)
			else:
				gap.append(len(stack))
				stack = [i]
		gap.append(len(stack))
		g2 = list(gap)
		g2 = g2[::-1]
		g2 = [len(g2)] + g2
		final = ' '.join([str(i) for i in g2])
		part2 = []
		st = 0
		for i in gap:
			temp = perm[st:st + i]
			part2.append(temp)
			st += i
		ans.append(final)
		part2 = part2[::-1]
		perm = []
		for i in part2:
			perm += i
	if perm == arr:
		pass
	else:
		ele = perm.pop(0)
		perm.append(ele)
		if arr == perm:
			ans.append('{} {} {}'.format(2, n - 1, 1))
		else:
			ans.append('{} {} {}'.format(2, 1, n - 1))
			ele = perm.pop()
			perm = [ele] + perm
	ans = ans[::-1]
	print(len(ans))
	for i in ans:
		print(i)


from sys import stdin, stdout

def unshuffling_a_deck(n, c_a):
	res_a = []
	while True:
		dic = {}
		a = b = c = -1
		for i in range(n):
			if c_a[i] in dic:
				a = dic[c_a[i]]
				c = i
				break
			dic[c_a[i] - 1] = i
		if a == -1:
			break
		b = a + 1
		while b < c and c_a[b] - 1 == c_a[b - 1]:
			b += 1
		q = []
		res = []
		if a - 1 >= 0:
			q.append(c_a[0:a])
			res.append(len(q[-1]))
		if b - 1 >= a:
			q.append(c_a[a:b])
			res.append(len(q[-1]))
		if c >= b:
			q.append(c_a[b:c + 1])
			res.append(len(q[-1]))
		if n - 1 >= c + 1:
			q.append(c_a[c + 1:n])
			res.append(len(q[-1]))
		s = str(len(res))
		for v in res:
			s += ' ' + str(v)
		res_a.append(s)
		q.reverse()
		idx = 0
		for bl in q:
			for v in bl:
				c_a[idx] = v
				idx += 1
	return res_a
n = int(stdin.readline())
c_a = list(map(int, stdin.readline().split()))
res_a = unshuffling_a_deck(n, c_a)
stdout.write(str(len(res_a)) + '\n')
stdout.write('\n'.join(res_a))


import sys

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def string(s):
	return ''.join(s)

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def bo(i):
	return ord(i) - ord('A')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def cil(n, m):
	return n // m + int(n % m > 0)

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < m and (a[i][j] != '.')

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = 1
while t > 0:
	t -= 1
	n = fi()
	a = li()
	ans = []
	for _ in range(n):
		vis = {}
		for i in range(n):
			if a[i] + 1 in vis:
				j = i - 1
				while j >= 0 and a[j] == a[j + 1] - 1:
					j -= 1
				p = [vis[a[i] + 1], j - vis[a[i] + 1] + 1, i - j, n - i - 1]
				if p[0] == 0:
					p = p[1:]
				if p[-1] == 0:
					p = p[:-1]
				ans.append([len(p)] + p)
				break
			vis[a[i]] = i
		d = []
		c = 0
		if a == sorted(a):
			break
		for j in p:
			d.append(a[c:c + j])
			c = c + j
		a = []
		for i in range(len(d) - 1, -1, -1):
			a += d[i]
	print(len(ans))
	for i in ans:
		print(*i)


def shuff(splitarray, c):
	temp = []
	temp2 = []
	for i in range(len(c)):
		if i in splitarray:
			temp.append(temp2)
			temp2 = []
		temp2.append(c[i])
	temp.append(temp2)
	c2 = []
	for te in reversed(temp):
		for i in te:
			c2.append(i)
	return c2

def put2IndexesTogether(idx1L, idx1R, idx2L, idx2R):
	splitarray = [idx2L, idx2R + 1, idx1R + 1]
	splitarray2 = []
	for i in splitarray:
		if 1 <= i < n:
			splitarray2.append(i)
	return splitarray2

def convertSplitArray(splitarray):
	splitarray.append(n)
	latest = 0
	sizes = []
	for x in splitarray:
		sizes.append(x - latest)
		latest = x
	sizes2 = []
	for sz in sizes:
		if sz > 0:
			sizes2.append(sz)
	return sizes2
n = int(input())
c = [int(x) for x in input().split()]
splitarrays = []
sortedIs = set()
while True:
	idxof = dict()
	for i in range(n):
		idxof[c[i]] = i
	ok = True
	for i in range(1, n):
		if i not in sortedIs and idxof[i + 1] < idxof[i]:
			sortedIs.add(i)
			idx1R = idxof[i]
			idx1L = idx1R
			while idx1L - 1 >= 0 and c[idx1L - 1] + 1 == c[idx1L]:
				idx1L -= 1
			idx2L = idxof[i + 1]
			idx2R = idx2L
			while idx2R + 1 < n and c[idx2R + 1] == c[idx2R] + 1:
				idx2R += 1
			splitarray = put2IndexesTogether(idx1L, idx1R, idx2L, idx2R)
			splitarrays.append(splitarray)
			c = shuff(splitarray, c)
			ok = False
			break
	if ok:
		break
ans = []
for x in splitarrays:
	ans.append(convertSplitArray(x))
print(len(ans))
for x in ans:
	s = str(len(x))
	s = s + ' ' + ' '.join([str(y) for y in x])
	print(s)


import sys
input = sys.stdin.readline
n = int(input())
C = list(map(int, input().split()))
ALIST = []
LASTCARD = list(range(1, n + 1))
if C == LASTCARD:
	print(0)
	sys.exit()

def first(C, x):
	ANS = [n]
	MIN = 1
	for i in range(n - 1, -1, -1):
		if C[i] == MIN:
			if i != 0:
				ANS.append(i)
			MIN += 1
			if MIN > x:
				break
	ANS.append(0)
	ANS.reverse()
	A = []
	for i in range(1, len(ANS)):
		A.append(ANS[i] - ANS[i - 1])
	if len(A) == 1:
		return C
	ALIST.append(A)
	C2 = []
	for i in range(1, len(ANS)):
		C2 += [C[ANS[i - 1]:ANS[i]]]
	C = []
	for c2 in C2[::-1]:
		C += c2
	return C

def last(C, x):
	ANS = [0]
	MIN = 1
	for i in range(n):
		if C[i] == MIN:
			if i != n - 1:
				ANS.append(i + 1)
			MIN += 1
			if MIN > x:
				break
	if ANS[-1] != n:
		ANS.append(n)
	A = []
	for i in range(1, len(ANS)):
		A.append(ANS[i] - ANS[i - 1])
	if len(A) == 1:
		return C
	ALIST.append(A)
	C2 = []
	for i in range(1, len(ANS)):
		C2 += [C[ANS[i - 1]:ANS[i]]]
	C = []
	for c2 in C2[::-1]:
		C += c2
	return C
LASTCARD = list(range(1, n + 1))
for i in range(1, n + 1):
	if i % 2 == 1:
		C = first(C, i)
	else:
		C = last(C, i)
	if C == LASTCARD:
		break
print(len(ALIST))
for la in ALIST:
	print(len(la), *la)


n = int(input())
cards = list(map(int, input().split()))
ans = []
for step in range(n):
	for i in range(1, n + 1):
		if i == n:
			print(len(ans))
			for p in ans:
				segments = [p[0], p[1] - p[0], p[2] - p[1], n - p[2]]
				print(4 - segments.count(0), end=' ')
				for e in segments:
					if e != 0:
						print(e, end=' ')
				print()
			exit()
		if cards.index(i) > cards.index(i + 1):
			for j in range(cards.index(i + 1), n + 1):
				if j == n or j - cards.index(i + 1) != cards[j] - i - 1:
					ans.append([cards.index(i + 1), j, cards.index(i) + 1])
					cards = cards[cards.index(i) + 1:] + cards[j:cards.index(i) + 1] + cards[cards.index(i + 1):j] + cards[:cards.index(i + 1)]
					break
			break


def qw(n, l, r, reverse, otv, otv1, lis):
	if n - l - r == 1:
		if not reverse:
			print(len(otv1))
			index = 0
			for q in otv1:
				print(q, end=' ')
				for w in range(q):
					print(otv[index], end=' ')
					index += 1
				print()
		return 0
	kol = 0
	for i in range(l):
		otv.append(1)
		kol += 1
	t = []
	for i in range(len(lis)):
		t.append((lis[i], i))
	t.sort()
	if not reverse:
		ind = t[-1][1]
	else:
		ind = t[0][1]
	if ind == 0 and l == 0 and (r == 0):
		return qw(n, 1, 0, not reverse, otv, otv1, lis[1:])
	if ind == 0:
		kol += 1
		otv.append(len(lis))
		l1 = lis[1:]
	if ind > 0:
		kol += 2
		otv.append(ind)
		otv.append(len(lis) - ind)
		if ind == len(lis) - 1:
			l1 = lis[:-1]
		else:
			l1 = lis[ind + 1:] + lis[:ind]
	for i in range(r):
		otv.append(1)
		kol += 1
	otv1.append(kol)
	return qw(n, r + 1, l, not reverse, otv, otv1, l1)
n = int(input())
l = list(map(int, input().split()))
qw(n, 0, 0, True, [], [], l)
qw(n, 0, 0, False, [], [], l)


import sys
readline = sys.stdin.readline

def shuf(A, rev, x):
	res = []
	B = []
	if not rev:
		for i in range(x - 1):
			B = [A[i]] + B
			res.append(1)
		c = []
		for i in range(x - 1, N):
			c.append(A[i])
			if A[i] == x:
				break
		B = c + B
		res.append(len(c))
		c = []
		for j in range(i + 1, N):
			c.append(A[j])
		B = c + B
		res.append(len(c))
		res = [r for r in res if r]
		if not res:
			B = A[::-1]
			res = [1] * N
	if rev:
		c = []
		for i in range(N):
			if A[i] == x:
				break
			c.append(A[i])
		B = c + B
		res.append(len(c))
		c = []
		for j in range(i, N):
			if A[j] <= x - 1:
				break
			c.append(A[j])
		B = c + B
		res.append(len(c))
		if 1 != x:
			for k in range(j, N):
				res.append(1)
				B = [A[k]] + B
		res = [r for r in res if r]
		if not res:
			B = A[::-1]
			res = [1] * N
	return (B, res)
N = int(readline())
A = list(map(int, readline().split()))
if N == 1:
	print(0)
else:
	Ans = []
	for i in range(N):
		(A, res) = shuf(A, N - i & 1, i + 1)
		if res != [N]:
			Ans.append(' '.join(map(str, [len(res)] + res)))
	print(len(Ans))
	print('\n'.join(Ans))


n = int(input())
l = input().split()
li = [int(i) for i in l]
l = []
if n == 1:
	print(0)
	quit()
xori = 0
if li[0] != 1:
	for i in range(n):
		if li[i] == 1:
			l.append((i, n - i))
			z = []
			for j in li[i:]:
				z.append(j)
			for j in li[:i]:
				z.append(j)
			li = list(z)
			break
for i in range(n - 2):
	for j in range(n):
		if li[j] == i + 2:
			if xori == 0:
				z = []
				for k in range(i + 1):
					z.append(1)
				z.append(j - i)
				if n - (j + 1):
					z.append(n - j - 1)
				l.append(list(z))
				xori = 1
				p = []
				z.reverse()
				sumi = n
				for i in z:
					for j in li[sumi - i:sumi]:
						p.append(j)
					sumi -= i
				li = list(p)
				break
			else:
				z = []
				if j > 0:
					z.append(j)
				z.append(n - i - 1 - j)
				for k in range(i + 1):
					z.append(1)
				xori = 0
				p = []
				l.append(list(z))
				z.reverse()
				sumi = n
				for i in z:
					for j in li[sumi - i:sumi]:
						p.append(j)
					sumi -= i
				li = list(p)
				break
print(len(l) + xori)
for i in l:
	print(len(i))
	for j in i:
		print(j, end=' ')
	print()
if xori == 1:
	print(n)
	for i in range(n):
		print(1, end=' ')


def final(b, a):
	c = []
	l = 0
	for i in range(b[0]):
		r = l + b[i + 1]
		c.append(a[l:r])
		l = r
	d = []
	n = len(c)
	for i in range(n - 1, -1, -1):
		for j in c[i]:
			d.append(j)
	return d
n = int(input())
a = list(map(int, input().split()))
b = []
c = sorted(a)
while a != c:
	d = []
	for i in range(n):
		if a[i] != i + 1:
			ind = i
			break
	ind1 = a.index(a[ind] - 1)
	cnt = 2
	if ind > 0:
		cnt += 1
	if ind1 < n - 1:
		cnt += 1
	d.append(cnt)
	if ind > 0:
		d.append(ind)
	cnt = 1
	ptr = a[ind] - 2
	for i in range(ind1 - 1, -1, -1):
		if a[i] == ptr:
			ptr -= 1
			cnt += 1
		else:
			break
	d.append(ind1 - cnt - ind + 1)
	d.append(cnt)
	if ind1 < n - 1:
		d.append(n - 1 - ind1)
	a = final(d, a)
	b.append(d)
print(len(b))
for i in b:
	for j in i:
		print(j, end=' ')
	print()


n = int(input())
u = list(map(int, input().split()))
ans = []
while True:
	x = -1
	for i in range(n, 1, -1):
		if u.index(i) < u.index(i - 1):
			x = i
			break
	else:
		break
	ind1 = u.index(x)
	ind2 = u.index(x - 1)
	cur = [ind1]
	dv = ind2
	for i in range(ind1 + 1, ind2):
		if u[i] != u[i - 1] + 1:
			dv = i
			break
	cur.append(dv - ind1)
	cur.append(ind2 - dv + 1)
	cur.append(n - ind2 - 1)
	if cur[0] == 0:
		cur = cur[1:]
	if cur[-1] == 0:
		cur.pop()
	ans.append(' '.join(map(str, [len(cur)] + cur)))
	for i in range(1, len(cur)):
		cur[i] += cur[i - 1]
	if len(cur) == 2:
		u = u[cur[1]:] + u[cur[0]:cur[1]] + u[:cur[0]]
	elif len(cur) == 3:
		u = u[cur[2]:] + u[cur[1]:cur[2]] + u[cur[0]:cur[1]] + u[:cur[0]]
	else:
		u = u[cur[3]:] + u[cur[2]:cur[3]] + u[cur[1]:cur[2]] + u[cur[0]:cur[1]] + u[:cur[0]]
print(len(ans))
print('\n'.join(ans))


import sys
import random
from typing import NamedTuple
input = sys.stdin.readline

class Segment(NamedTuple):
	start: int
	end: int

	@property
	def size(self):
		return self.end - self.start + 1

def shuffle(a, sizes):
	n = len(a)
	assert len(sizes) > 1, len(sizes)
	assert sum(sizes) == len(a), (sum(sizes), n)
	result = [None for i in range(n)]
	offset = 0
	for size in sizes:
		assert size > 0, size
		segment = A[offset:offset + size]
		result[n - offset - size:n - offset] = segment
		offset += size
	return result

def split_into_segments(a):
	n = len(a)
	result = []
	size = 1
	for i in range(1, n):
		if a[i] == a[i - 1] + 1:
			size += 1
		else:
			segment = Segment(start=a[i - size], end=a[i - 1])
			result.append(segment)
			size = 1
	result.append(Segment(start=a[n - size], end=a[n - 1]))
	assert sum((segment.size for segment in result)) == n
	return result
N = int(input())
A = list(map(int, input().split()))
ans = []
segments = split_into_segments(A)
while len(segments) > 1:
	K = len(segments)
	split = None
	for i in range(K - 1):
		for j in range(i + 1, K):
			if segments[i].start == segments[j].end + 1:
				split = list(filter(None, [sum((segments[k].size for k in range(i))) if i else 0, sum((segments[k].size for k in range(i, j))), segments[j].size, sum((segments[k].size for k in range(j + 1, K))) if j != K - 1 else 0]))
				break
		if split is not None:
			break
	ans.append(split)
	A = shuffle(A, split)
	segments = split_into_segments(A)
print(len(ans))
for operation in ans:
	print(len(operation), end=' ')
	print(' '.join(map(str, operation)))


n = int(input())
l = list(map(int, input().split()))
odd = l.copy()
l.sort()
even = []
c = 0
ans = []
for i in range(n):
	ll = []
	cool = n
	count = 1
	tt = 0
	if c == 0:
		if odd == l:
			break
		j = 0
		while j < n - 1:
			if odd[j + 1] < odd[j]:
				count += 1
				if j == n - 2:
					ll.append(count)
					tt += count
				j += 1
			else:
				j += 1
				ll.append(count)
				tt += count
				count = 1
		if n - tt > 0:
			ll.append(n - tt)
		for j in range(len(ll) - 1, -1, -1):
			for k in range(cool - ll[j], cool):
				even.append(odd[k])
			cool -= ll[j]
		ans.append(ll)
		c = 1
		odd = []
	else:
		if even == l:
			break
		j = 0
		while j < n - 1:
			if even[j + 1] > even[j]:
				count += 1
				if j == n - 1:
					ll.append(count)
					tt += count
			else:
				ll.append(count)
				tt += count
				count = 1
			j += 1
		if n - tt > 0:
			ll.append(n - tt)
		for j in range(len(ll) - 1, -1, -1):
			for k in range(cool - ll[j], cool):
				odd.append(even[k])
			cool -= ll[j]
		c = 0
		ans.append(ll)
		even = []
if len(ans) == 0:
	print(0)
else:
	anss = []
	for i in ans:
		if len(i) != 1:
			anss.append(i)
	print(len(anss))
	for i in anss:
		print(len(i), end=' ')
		print(*i)


n = int(input())
deck = [int(i) for i in input().split()]
ops = []
while True:
	grouping_starts = [0]
	for i in range(1, len(deck)):
		if deck[i] != deck[i - 1] + 1:
			grouping_starts.append(i)
	if len(grouping_starts) == 1:
		break
	grouping_starts.append(n)
	if deck[0] != 1:
		for i in range(2, len(grouping_starts)):
			start = grouping_starts[i]
			if deck[start - 1] == deck[0] - 1:
				grouping_starts = [0, grouping_starts[i - 1], grouping_starts[i], n]
				if grouping_starts[-2] == n:
					grouping_starts.pop()
				break
	else:
		second_group_start_val = deck[grouping_starts[1]]
		for i in range(3, len(grouping_starts)):
			start = grouping_starts[i]
			if deck[start - 1] == second_group_start_val - 1:
				grouping_starts = [0, grouping_starts[1], grouping_starts[i - 1], grouping_starts[i], n]
				if grouping_starts[-2] == n:
					grouping_starts.pop()
				break
	op = [len(grouping_starts) - 1]
	new_deck = []
	for i in range(len(grouping_starts) - 1):
		start = grouping_starts[i]
		end = grouping_starts[i + 1]
		new_deck = deck[start:end] + new_deck
		op.append(end - start)
	deck = new_deck
	ops.append(' '.join((str(i) for i in op)))
assert len(ops) <= n
print(len(ops))
if ops:
	print(*ops, sep='\n')


import sys, os, io
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
sample = list(range(1, N + 1))
anss = []
while A != sample:
	ans = []
	lis = [-1] * (N + 2)
	for i in range(N):
		if lis[A[i] + 1] >= 0:
			(p, q) = (lis[A[i] + 1], i)
			break
		lis[A[i]] = i
	B = []
	if p > 0:
		ans.append(p)
		B.append(A[:p])
	for i in range(p, q):
		if A[i] > A[i + 1]:
			ans.append(i - p + 1)
			B.append(A[p:i + 1])
			ans.append(q - i)
			B.append(A[i + 1:q + 1])
			break
	if q < N - 1:
		ans.append(N - q - 1)
		B.append(A[q + 1:])
	anss.append((len(ans), *ans))
	A = []
	for b in B[::-1]:
		A += b
print(len(anss))
for ans in anss:
	print(*ans)


n = int(input())
a = [int(i) for i in input().split()]
fin = []
for it in range(n):
	gr = []
	i = 0
	while i < n:
		j = i + 1
		while j < n and a[j - 1] + 1 == a[j]:
			j += 1
		gr.append((i, j - i))
		i = j
	if len(gr) == 1:
		break
	res = []
	if a[0] == 1:
		si = gr[1][0]
		for i in range(len(gr)):
			ci = gr[i][0]
			cl = gr[i][1]
			if a[ci + cl - 1] + 1 == a[si]:
				res = [gr[0], (si, ci - si), gr[i], (ci + cl, n - (ci + cl))]
				break
		if res[-1][1] == 0:
			res.pop()
	else:
		for i in range(len(gr)):
			ci = gr[i][0]
			cl = gr[i][1]
			if a[ci + cl - 1] + 1 == a[0]:
				res = [(0, ci), gr[i], (ci + cl, n - (ci + cl))]
				break
		if res[-1][1] == 0:
			res.pop()
	na = []
	fin.append([])
	for v in res:
		fin[-1].append(v[1])
	for v in reversed(res):
		na += a[v[0]:v[0] + v[1]]
	a = na.copy()
print(len(fin))
for i in range(len(fin)):
	print(len(fin[i]), end=' ')
	print(*fin[i])


import sys
input = sys.stdin.readline

def revert(arr):
	c = []
	for i in arr:
		c += i
	return c
n = int(input())
c = [int(i) for i in input().split() if i != '\n']
copy = [int(i) for i in range(1, n + 1)]
ans = []
while c != copy:
	(r_order, to_find, ind, ok) = ([], 0, n, False)
	for i in range(n - 1, -1, -1):
		if c[i] != copy[i]:
			if i + 1 < n:
				r_order.append(c[i + 1:])
			to_find = c[i] + 1
			ind = i
			break
	for i in range(ind, 0, -1):
		if c[i - 1] != c[i] - 1 and ok == False:
			ok = True
			r_order.append(c[i:ind + 1])
			ind = i
			break
	for i in range(ind, 0, -1):
		if c[i] == to_find:
			r_order.append(c[i:ind])
			ind = i
			break
	if ind > 0:
		r_order.append(c[:ind])
	length = []
	for i in r_order:
		length.append(len(i))
	length.reverse()
	length.insert(0, len(r_order))
	ans.append(length)
	c = revert(r_order)
sys.stdout.write(str(len(ans)) + '\n')
for i in ans:
	i = ' '.join(map(str, i))
	sys.stdout.write(i + '\n')


import sys
from collections import deque
n = int(input())
arr = list(map(int, sys.stdin.readline().strip().split()))
ans = []
while True:
	idx_kel_akhir = n - 1
	while idx_kel_akhir > 0 and arr[idx_kel_akhir - 1] == arr[idx_kel_akhir] - 1:
		idx_kel_akhir -= 1
	if idx_kel_akhir == 0:
		break
	if arr[-1] != n:
		idx_pasang = idx_kel_akhir - 1
		while arr[idx_pasang] != arr[-1] + 1:
			idx_pasang -= 1
		if idx_pasang == 0:
			ans.append([idx_kel_akhir, n - idx_kel_akhir])
		else:
			ans.append([idx_pasang, idx_kel_akhir - idx_pasang, n - idx_kel_akhir])
	else:
		idx_kel_akhir_dua = idx_kel_akhir - 1
		while arr[idx_kel_akhir_dua - 1] == arr[idx_kel_akhir_dua] - 1:
			idx_kel_akhir_dua -= 1
		idx_pasang = idx_kel_akhir_dua - 1
		while arr[idx_pasang] != arr[idx_kel_akhir - 1] + 1:
			idx_pasang -= 1
		if idx_pasang == 0:
			ans.append([idx_kel_akhir_dua, idx_kel_akhir - idx_kel_akhir_dua, n - idx_kel_akhir])
		else:
			ans.append([idx_pasang, idx_kel_akhir_dua - idx_pasang, idx_kel_akhir - idx_kel_akhir_dua, n - idx_kel_akhir])
	sem = deque([])
	batas_idx = int(0)
	for tambah in ans[-1]:
		bef = batas_idx
		batas_idx += tambah
		for i in range(batas_idx - 1, bef - 1, -1):
			sem.appendleft(arr[i])
	for i in range(n):
		arr[i] = sem[i]
print(len(ans))
for L in ans:
	sys.stdout.write(str(len(L)))
	for i in L:
		sys.stdout.write(' ' + str(i))
	print()


n = int(input())
a = list(map(int, input().split()))
res = []
for _ in range(n):
	li = []
	flag = False
	for i in range(n):
		if flag:
			break
		for j in range(i + 1, n):
			if a[i] - 1 == a[j]:
				cnt1 = 1
				for k in range(i, j):
					if a[k] + 1 == a[k + 1]:
						cnt1 += 1
					else:
						break
				if i > 0:
					li.append(i)
				li.append(cnt1)
				li.append(j - i + 1 - cnt1)
				if n - (j + 1) > 0:
					li.append(n - (j + 1))
				flag = True
				break
	if not li:
		break
	else:
		res.append(li)
	(l, r) = (n, n)
	ind = 0
	b = [0] * n
	for val in li[::-1]:
		l = l - val
		for i in range(l, r):
			b[ind] = a[i]
			ind += 1
		r = l
	a = b[:]
print(len(res))
for r in res:
	print(len(r), *r)


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	n = mint()
	c = list(mints())
	if n == 1:
		print(0)
		return
	want = list(range(1, n + 1)) if n % 2 == 0 else list(range(n, 0, -1))
	zs = 1
	ze = n + 1
	if {c.index(1), want.index(1)} == {0, n - 1}:
		print(n - 1)
		print(n, *[1] * n)
		c.reverse()
		zs = 2
		ze = n
	else:
		print(n)
	for i in range(zs, ze):
		idx = c.index(i)
		idxw = want.index(i)
		if idx == idxw:
			print(n, *[1] * n)
			c.reverse()
		else:
			if idx > idxw:
				(idxw, idx) = (idx, idxw)
			z = [1] * idx + [idxw - idx + 1] + [1] * (n - idxw - 1)
			if sum(z) != n:
				raise Exception('wut')
			print(len(z), end=' ')
			print(*z)
			p = n
			cn = []
			for jj in range(len(z) - 1, -1, -1):
				j = z[jj]
				for i in range(p - j, p):
					cn.append(c[i])
				p -= j
			c = cn
		want.reverse()
solve()


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	if n % 2 == 0:
		k = a.index(1)
		ans.append([k + 1, n - k - 1])
		done = 1
		rv = 1
		a = a[k + 1:] + a[:k + 1]
		for i in range(1, n):
			if rv:
				k = a.index(done + 1)
				l = a.index(done)
				ans.append([k, l - k] + [1] * done)
				a = a[l:][::-1] + a[k:l] + a[:k]
				done += 1
				rv = 0
			else:
				k = a.index(done + 1)
				l = a.index(done)
				ans.append([1] * done + [k - l, n - k - 1])
				a = a[k + 1:] + a[l + 1:k + 1] + a[:l + 1][::-1]
				done += 1
				rv = 1
	else:
		k = a.index(1)
		ans.append([k, n - k])
		done = 1
		rv = 0
		a = a[k:] + a[:k]
		for i in range(1, n):
			if rv:
				k = a.index(done + 1)
				l = a.index(done)
				ans.append([k, l - k] + [1] * done)
				a = a[l:][::-1] + a[k:l] + a[:k]
				done += 1
				rv = 0
			else:
				k = a.index(done + 1)
				l = a.index(done)
				ans.append([1] * done + [k - l, n - k - 1])
				a = a[k + 1:] + a[l + 1:k + 1] + a[:l + 1][::-1]
				done += 1
				rv = 1
	for i in ans:
		while 0 in i:
			i.remove(0)
		if len(i) <= 1:
			ans.remove(i)
	print(len(ans))
	for i in ans:
		while 0 in i:
			i.remove(0)
		print(len(i), *i)

def main():
	t = 1
	for _ in range(t):
		solve()
main()


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def LI1():
	return list(map(int1, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
n = II()
aa = LI1()
pos = [-1] * n
ans = []
while 1:
	for (i, a) in enumerate(aa):
		pos[a] = i
	for a in range(n - 1):
		if pos[a] > pos[a + 1]:
			s = pos[a + 1]
			e = pos[a]
			for i in range(s, e):
				if aa[i] + 1 != aa[i + 1]:
					m = i + 1
					break
			if s > 0 and e + 1 < n:
				a0 = aa[:s]
				a1 = aa[s:m]
				a2 = aa[m:e + 1]
				a3 = aa[e + 1:]
				ans.append((len(a0), len(a1), len(a2), len(a3)))
				aa = a3 + a2 + a1 + a0
			elif s > 0:
				a0 = aa[:s]
				a1 = aa[s:m]
				a2 = aa[m:]
				ans.append((len(a0), len(a1), len(a2)))
				aa = a2 + a1 + a0
			elif e + 1 < n:
				a1 = aa[:m]
				a2 = aa[m:e + 1]
				a3 = aa[e + 1:]
				ans.append((len(a1), len(a2), len(a3)))
				aa = a3 + a2 + a1
			else:
				a1 = aa[:m]
				a2 = aa[m:]
				ans.append((len(a1), len(a2)))
				aa = a2 + a1
			break
	else:
		break
print(len(ans))
for a in ans:
	print(len(a), *a)


n = int(input())
c = list(map(int, input().split()))
ans = []
while True:
	seen = [False] * 60
	for i in range(n):
		if seen[c[i] + 1]:
			break
		seen[c[i]] = True
	else:
		break
	if i + 1 < n:
		sep = [i + 1]
	else:
		sep = []
	flg = True
	for j in range(i - 1, -1, -1):
		if c[j] + 1 != c[j + 1] and flg:
			sep.append(j + 1)
			flg = False
		if c[j] == c[i] + 1:
			if j > 0:
				sep.append(j)
			break
	sep += [0, n]
	sep.sort()
	tmp = []
	nc = []
	for i in range(len(sep) - 1):
		tmp.append(sep[i + 1] - sep[i])
	for i in range(len(sep) - 2, -1, -1):
		nc += c[sep[i]:sep[i + 1]]
	ans.append(tmp)
	c = nc
print(len(ans))
for i in ans:
	i = [len(i)] + i
	print(*i)


import sys
from sys import stdin

def sc(cut):
	D = []
	now = 0
	for i in cut:
		D.append(c[now:now + i])
		now += i
	D.reverse()
	ret = []
	for i in D:
		for j in i:
			ret.append(j)
	return ret

def remzero(cut):
	ret = []
	for i in cut:
		if i != 0:
			ret.append(i)
	if sum(ret) != N:
		ret.append(N - sum(ret))
	return ret
N = int(stdin.readline())
c = list(map(int, stdin.readline().split()))
ans = []
order = 0
for X in range(2, N + 1):
	if order == 0:
		Mind = None
		Xind = None
		for i in range(N):
			if c[i] == 1:
				Mind = i
			elif c[i] == X:
				Xind = i
		cut = []
		if Mind < Xind:
			cut.append(Mind)
			for i in range(X - 1):
				cut.append(1)
			cut.append(Xind + 1 - (Mind + X - 1))
			order ^= 1
		else:
			cut.append(Xind)
			cut.append(Mind - Xind)
			cut.append(X - 1)
		cut = remzero(cut)
		ans.append(cut)
		c = sc(cut)
	else:
		c.reverse()
		Mind = None
		Xind = None
		for i in range(N):
			if c[i] == 1:
				Mind = i
			elif c[i] == X:
				Xind = i
		cut = []
		if Mind < Xind:
			cut.append(Mind)
			for i in range(X - 1):
				cut.append(1)
			cut.append(Xind + 1 - (Mind + X - 1))
			order ^= 1
		else:
			cut.append(Xind)
			cut.append(Mind - Xind)
			cut.append(X - 1)
		cut = remzero(cut)
		c = sc(cut)
		cut.reverse()
		c.reverse()
		ans.append(cut)
if order == 1:
	ans.append([1] * N)
	c = sc([1] * N)
print(len(ans))
for i in ans:
	print(len(i), *i)
print(c, file=sys.stderr)


ans = []

def doRev(arr):
	preAns = [len(arr), *[1] * len(arr)]
	ans.append(preAns)
	return list(reversed(arr))

def do(arr, splits):
	splits.append(len(arr))
	splits = list(set(splits))
	splits.sort()
	preAns = [len(splits)]
	l = 0
	for i in range(len(splits)):
		preAns.append(splits[i] - l)
		l = splits[i]
	ans.append(preAns)
	newArr = []
	l = 0
	for i in range(len(splits)):
		newArr.append(arr[l:splits[i]])
		l = splits[i]
	newArr.reverse()
	new = []
	for i in range(len(newArr)):
		for g in range(len(newArr[i])):
			new.append(newArr[i][g])
	return new

def doinotherway(arr):
	n = len(arr)
	arr = arr
	it = 0
	while it < n + 10:
		it += 1
		f = arr[0]
		if f == 1:
			if arr == list(reversed(list(sorted(arr)))):
				arr = doRev(arr)
			else:
				more = 0
				for i in range(1, n):
					if arr[i] == arr[i - 1] + 1:
						more += 1
					else:
						break
				arr = do(arr, [more + 1])
		else:
			more = 0
			for i in range(1, n):
				if arr[i] != arr[i - 1] + 1:
					break
				else:
					more += 1
			ind = 0
			for i in range(n):
				if arr[i] == f - 1:
					ind = i
					break
			more2 = 0
			for i in range(ind - 1, -1, -1):
				if arr[i] != arr[i + 1] - 1:
					break
				else:
					more2 += 1
			arr = do(arr, [ind - more2, ind + 1])
		if arr == list(reversed(list(sorted(arr)))):
			arr = doRev(arr)
		if arr == list(sorted(arr)):
			break

def donormal(arr):
	n = len(arr)
	arr = arr
	it = 0
	while it < n + 10:
		it += 1
		f = arr[0]
		if f == n:
			if arr == list(reversed(list(sorted(arr)))):
				arr = doRev(arr)
			else:
				more = 0
				for i in range(1, n):
					if arr[i] == arr[i - 1] - 1:
						more += 1
					else:
						break
				arr = do(arr, [more + 1])
		else:
			more = 0
			for i in range(1, n):
				if arr[i] != arr[i - 1] - 1:
					break
				else:
					more += 1
			ind = 0
			for i in range(n):
				if arr[i] == f + 1:
					ind = i
					break
			more2 = 0
			for i in range(ind - 1, -1, -1):
				if arr[i] != arr[i + 1] + 1:
					break
				else:
					more2 += 1
			arr = do(arr, [ind - more2, ind + 1])
		if arr == list(reversed(list(sorted(arr)))):
			arr = doRev(arr)
		if arr == list(sorted(arr)):
			break

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	c = arr[:]
	if n == 1 or arr == list(sorted(arr)):
		print(0)
		return 0
	donormal(arr)
	global ans
	if len(ans) <= n:
		print(len(ans))
		for i in range(len(ans)):
			print(*ans[i])
	else:
		ans = []
		doinotherway(c)
		print(len(ans))
		for i in range(len(ans)):
			print(*ans[i])
solve()


n = int(input())
if n == 1:
	print(0)
	exit(0)
l = list(map(int, input().split()))
qrs = []

def isSorted(l):
	for i in range(1, len(l)):
		if l[i - 1] > l[i]:
			return False
	return True

def applyOp(l, ops):
	last = 0
	block = []
	for sz in ops:
		block.append(l[last:last + sz])
		last += sz
	block = block[::-1]
	newl = []
	for b in block:
		newl.extend(b)
	return newl
for t in range(2, n + 1):
	isReversed = False
	if l.index(1) > l.index(2):
		l = l[::-1]
		isReversed = True
	pv = l.index(t)
	tg = l.index(t - 1)
	if pv != 0 and tg == pv - 1:
		if isReversed:
			l = l[::-1]
		continue
	cur = []
	if pv < tg:
		if pv == 0:
			cur = [1, tg, n - tg - 1]
		else:
			cur = [pv, 1, tg - pv, n - 1 - tg]
	elif pv == n - 1:
		cur = [tg - t + 2] + [1] * (t - 1) + [n - tg - 1]
	else:
		cur = [tg - t + 2] + [1] * (t - 1) + [pv - tg, n - pv - 1]
	ncur = []
	for i in cur:
		if i > 0:
			ncur.append(i)
		elif i < 0:
			while True:
				pass
	cur = ncur
	if isReversed:
		l = l[::-1]
		cur = cur[::-1]
	qrs.append(cur)
	l = applyOp(l, cur)
if l.index(1) > l.index(2):
	qrs.append([1] * n)
print(len(qrs))
for qr in qrs:
	print(len(qr), ' '.join(map(str, qr)))


n = int(input())
d = list(map(int, input().split()))
l = []
while True:
	for i in range(n):
		a = d[i]
		for j in range(i + 1, n):
			if d[j] == a - 1:
				p = (i, j)
				break
		else:
			continue
		break
	else:
		break
	ai = i
	while ai + 1 < n and d[ai + 1] == d[ai] + 1:
		ai += 1
	nl = []
	if i != 0:
		nl.append(i)
	nl.append(ai - i + 1)
	nl.append(j - ai)
	if j != n - 1:
		nl.append(n - j - 1)
	l.append(nl)
	d = d[j + 1:] + d[ai + 1:j + 1] + d[i:ai + 1] + d[:i]
print(len(l))
for i in l:
	print(len(i), *i)


import os, sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd
from _collections import deque
import heapq as hp
from bisect import bisect_left, bisect_right
from math import cos, sin
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7
n = int(input())
a = [[i, 1] for i in map(int, input().split())]
ck = [a[0] + [0]]
for i in range(1, n):
	if sum(ck[-1][:2]) == a[i][0]:
		ck[-1][1] += a[i][1]
	else:
		ck.append(a[i] + [ck[-1][2] + 1])
a = ck
ans = []
while True:
	ck = sorted(a)
	f = -1
	l = -1
	for i in range(1, len(ck)):
		if sum(ck[i - 1][:2]) == ck[i][0] and ck[i - 1][2] > ck[i][2]:
			f = ck[i][2]
			l = ck[i - 1][2]
			break
	if f == -1:
		break
	tot1 = tot2 = tot3 = tot4 = 0
	c1 = []
	c2 = []
	c3 = []
	c4 = []
	for i in range(f):
		tot1 += a[i][1]
		c1.append(a[i])
	tot2 += a[f][1]
	c2.append(a[f])
	for i in range(f + 1, l + 1):
		tot3 += a[i][1]
		c3.append(a[i])
	for i in range(l + 1, len(ck)):
		tot4 += a[i][1]
		c4.append(a[i])
	tt = []
	if tot1:
		tt.append(tot1)
	if tot2:
		tt.append(tot2)
	if tot3:
		tt.append(tot3)
	if tot4:
		tt.append(tot4)
	if tt:
		ans.append([len(tt)] + tt)
	a = c4 + c3 + c2 + c1
	ck = [a[0]]
	ck[-1][2] = 0
	for i in range(1, len(a)):
		if sum(ck[-1][:2]) == a[i][0]:
			ck[-1][1] += a[i][1]
		else:
			ck.append(a[i])
			ck[-1][2] = ck[-2][2] + 1
	a = ck
print(len(ans))
for i in ans:
	print(*i)


n = int(input())
d = [int(i) for i in input().split()]
pr = []

def rev(ll):
	global d
	ll = [qq for qq in ll if qq]
	if len(ll) == 1:
		return
	assert len(ll) <= n
	pr.append(' '.join(map(str, [len(ll)] + ll)))
	psum = [0]
	for l in ll:
		psum.append(psum[-1] + l)
	dd = []
	for i in range(len(psum) - 2, -1, -1):
		dd += d[psum[i]:psum[i + 1]]
	d = dd
for i in range(n // 2):
	a = i + 1
	b = n - i
	i1 = d.index(a)
	i2 = d.index(b)
	if i1 < i2:
		rev([i, i1 - i + 1, i2 - i1 - 1, n - i2 - i, i])
		rev([i, 1, n - 2 * i - 2, 1, i])
	else:
		rev([i, i2 - i + 1, i1 - i2 - 1, n - i1 - i, i])
		rev([i, n - 2 * i, i])
print(len(pr))
[print(prr) for prr in pr]


n = int(input())
c = list(map(int, input().split()))
c2 = c[:]
out = []
for i in range(1, n):
	ind = c2.index(i)
	if i == ind + 1:
		continue
	sizes = [1] * (i - 1) + [ind - i + 2] + [1] * (n - ind - 1)
	if len(sizes) > 1:
		if c2 == c:
			sizesr = sizes
		else:
			sizesr = sizes[::-1]
		out.append(str(len(sizesr)) + ' ' + ' '.join(map(str, sizesr)))
		lists = []
		curr = 0
		for v in sizes:
			lists.append(c2[curr:curr + v])
			curr += v
		lists.reverse()
		c2 = []
		for l in lists:
			c2 += l
		lists = []
		curr = 0
		for v in sizesr:
			lists.append(c[curr:curr + v])
			curr += v
		lists.reverse()
		c = []
		for l in lists:
			c += l
	c2.reverse()
if c != c2:
	out.append(str(n) + ' 1' * n)
	c = c[::-1]
assert c == list(range(1, n + 1))
print(len(out))
print('\n'.join(out))


N = int(input())
D = [int(_) for _ in input().split()]
start = N // 2 + 1
operations = []

def apply(D, op, operations):
	actual_op = []
	Ls = []
	s = 0
	for sz in op:
		if sz == 0:
			continue
		Ls.append(D[s:s + sz])
		s += sz
		actual_op.append(sz)
	D = []
	for ls in Ls[::-1]:
		D.extend(ls)
	operations.append(actual_op)
	return (D, operations)
start_index = D.index(start)
if start_index > 0:
	(D, operations) = apply(D, [start_index, N - start_index], operations)
for i in range(1, N // 2 + 1):
	left_el = start - i
	if left_el > 0:
		index_left_el = D.index(left_el)
		(D, operations) = apply(D, [2 * i - 1, index_left_el + 1 - (2 * i - 1), N - (2 * i - 1) - (index_left_el + 1 - (2 * i - 1))], operations)
	right_el = start + i
	if right_el <= N:
		index_right_el = D.index(right_el)
		(D, operations) = apply(D, [index_right_el, N - index_right_el - 2 * i, 2 * i], operations)
print(len(operations))
for op in operations:
	print(len(op), ' '.join(map(str, op)))


n = int(input())
c = list(map(int, input().split()))
q = 0
k = []
d = []
x = 0
arr = []
if c[0] != 1:
	q += 1
	k.append(2)
	for i in range(n):
		if c[i] == 1:
			x = i
			break
	arr = [x, n - x]
	d.append([x, n - x])
	s = [0]
	for j in range(len(arr) - 1):
		s.append(s[-1] + arr[j])
	s.append(n)
	c1 = []
	for j in range(len(s) - 1, 0, -1):
		c1 += c[s[j - 1]:s[j]]
	c = c1
f = True
t = 1
for i in range(n - 2):
	if f:
		arr = []
		for _ in range(t):
			arr.append(1)
		for j in range(t, n):
			if c[j] == t + 1:
				x = j
				break
		arr.append(x - t + 1)
		if n > x + 1:
			arr.append(n - (x + 1))
			k.append(t + 2)
		else:
			k.append(t + 1)
		d.append(arr)
		s = [0]
		for j in range(len(arr) - 1):
			s.append(s[-1] + arr[j])
		s.append(n)
		c1 = []
		for j in range(len(s) - 1, 0, -1):
			c1 += c[s[j - 1]:s[j]]
		c = c1
		t += 1
		f = False
	else:
		arr = []
		for j in range(n):
			if c[j] == t + 1:
				x = j
				break
		if x > 0:
			arr.append(x)
			arr.append(n - x - t)
			k.append(t + 2)
		else:
			arr.append(n - t)
			k.append(t + 1)
		for _ in range(t):
			arr.append(1)
		d.append(arr)
		t += 1
		s = [0]
		for j in range(len(arr) - 1):
			s.append(s[-1] + arr[j])
		s.append(n)
		c1 = []
		for j in range(len(s) - 1, 0, -1):
			c1 += c[s[j - 1]:s[j]]
		c = c1
		f = True
if c[0] != 1:
	arr = []
	for _ in range(n):
		arr.append(1)
	d.append(arr)
	k.append(n)
print(len(k))
for i in range(len(k)):
	print(k[i], end=' ')
	print(*d[i])


import sys
input = sys.stdin.readline

def update(operations, c):
	if operations is None:
		return c
	new = []
	for i in operations:
		new.append(c[:i])
		c = c[i:]
	c2 = []
	for i in range(len(new) - 1, -1, -1):
		c2.extend(new[i])
	return c2

def prog():
	n = int(input())
	c = list(map(int, input().split()))
	fix_l = 1
	fix_r = n
	tot_moves = []
	for i in range(n // 2):
		idxl = c.index(fix_l)
		idxr = c.index(fix_r)
		moves1 = []
		moves2 = []
		if idxl > idxr:
			if fix_l > 1:
				moves1.append(fix_l - 1)
			moves1.append(n - (fix_l - 1) - (n - fix_r))
			if fix_r < n:
				moves1.append(n - fix_r)
			if len(moves1) == 1:
				moves1 = None
		else:
			if fix_l > 1:
				moves1.append(fix_l - 1)
			moves1 += [1] * (n - (fix_l - 1) - (n - fix_r))
			if fix_r < n:
				moves1.append(n - fix_r)
		c = update(moves1, c)
		idxl2 = c.index(fix_l)
		idxr2 = c.index(fix_r)
		if fix_r < n:
			moves2.append(n - fix_r)
		moves2.append(idxr2 - (n - fix_r) + 1)
		if idxl2 - idxr2 - 1 > 0:
			moves2.append(idxl2 - idxr2 - 1)
		moves2.append(n - idxl2 - (fix_l - 1))
		if fix_l > 1:
			moves2.append(fix_l - 1)
		c = update(moves2, c)
		if moves1 != None:
			tot_moves.append(moves1)
		tot_moves.append(moves2)
		fix_l += 1
		fix_r -= 1
	print(len(tot_moves))
	for move in tot_moves:
		print(len(move), *move)
prog()


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import Counter
from pprint import pprint

def main():
	n = int(input())
	arr = list(map(lambda x: int(x) - 1, input().split()))
	ans = []
	cnt = 0
	while True:
		if cnt > 100:
			assert False
		cnt += 1
		pos = n - 1
		while pos >= 0 and arr[pos] == pos:
			pos -= 1
		if pos < 0:
			break
		el = arr[pos]
		t = pos - 1
		prev = el
		while t >= 0 and arr[t] == prev - 1:
			prev -= 1
			t -= 1
		ind = arr.index(el + 1)
		arr = arr[pos + 1:] + arr[t + 1:pos + 1] + arr[ind:t + 1] + arr[:ind]
		lis = []
		if ind - 0 > 0:
			lis.append(ind - 0)
		if t + 1 - ind > 0:
			lis.append(t + 1 - ind)
		if pos + 1 - t - 1 > 0:
			lis.append(pos + 1 - t - 1)
		if n - pos - 1 > 0:
			lis.append(n - pos - 1)
		assert sum(lis) == n
		ans.append(lis)
	assert len(ans) <= n
	print(len(ans))
	for li in ans:
		print(len(li), *li)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(1):
	main()


import sys
input = sys.stdin.readline
n = int(input())
c = list(map(int, input().split()))
ac = []
f = int(n % 2 == 1)
for tar in range(1, n + 1)[::-1]:
	split = []
	cnt = 0
	if f:
		for i in range(n):
			cnt += 1
			if tar <= c[i]:
				split.append(cnt)
				cnt = 0
	else:
		for i in range(n)[::-1]:
			cnt += 1
			if tar <= c[i]:
				split.append(cnt)
				cnt = 0
	if cnt:
		split.append(cnt)
	if f == 0:
		split.reverse()
	if len(split) == 1:
		f ^= 1
		continue
	ac.append(split)
	new = []
	s = 0
	for i in range(len(split)):
		new.append(c[s:s + split[i]])
		s += split[i]
	new.reverse()
	new_arr = []
	for tmp in new:
		new_arr += tmp
	c = new_arr
	f ^= 1
print(len(ac))
for arr in ac:
	print(len(arr), *arr)


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def output(*args):
	sys.stdout.buffer.write(('\n'.join(map(str, args)) + '\n').encode('utf-8'))

def main():
	n = int(input())
	a = list(map(int, input().split()))
	sorted_a = sorted(a)
	ans = []

	def get_seg(a, x, used):
		flag = x == 1 or a.index(x - 1) < a.index(x)
		i = a.index(x)
		for (v, j) in enumerate(range(i, len(a)), start=x):
			if used[j] or (flag and a[j] != v):
				return (i, j)
			used[j] = 1
		return (i, len(a))
	while a != sorted_a:
		used = [0] * n
		segments = [get_seg(a, 1, used)]
		for x in range(2, n + 1):
			if not used[a.index(x)]:
				segments.append(get_seg(a, x, used))
		segments = [r - l for (l, r) in sorted(segments)]
		ans.append(f'{len(segments)} ' + ' '.join(map(str, segments)))
		next_a = []
		for seg in reversed(segments):
			next_a.extend(a[-seg:])
			a = a[:-seg]
		a = next_a
	if len(ans) > n:
		print(ans)
		raise Exception('aaa')
	output(str(len(ans)), '\n'.join(ans))
main()


import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import time
start_time = time.time()
import collections as col
import math
from functools import reduce

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def solve():
	N = getInt()
	A = getInts()
	ans_parts = []
	ans = 0
	for i in range(1, N + 1):
		for j in range(1, N):
			(ind_i, ind_j) = (A.index(j), A.index(j + 1))
			if ind_i > ind_j:
				ans += 1
				parts = []
				new_arr = []
				tot = 0
				if ind_j > 0:
					parts.append(ind_j)
					tot += ind_j
				x = ind_j
				while x + 1 < N and A[x + 1] == A[x] + 1:
					x += 1
				parts.append(x - ind_j + 1)
				tot += x - ind_j + 1
				parts.append(ind_i - x)
				tot += ind_i - x
				if N - tot:
					parts.append(N - tot)
				ans_parts.append((parts, len(parts)))
				A = A[ind_i + 1:] + A[x + 1:ind_i + 1] + A[ind_j:x + 1] + A[:ind_j]
				break
	print(ans)
	for (parts, len_p) in ans_parts:
		print(len_p, *parts)
	return
solve()


from sys import stdin, stdout
from math import gcd
input = stdin.readline
n = int(input())
(*a,) = map(int, input().split())
c = n & 1
if c and a[0] == 1 or (not c and a[-1] == 1):
	print(n - 1)
else:
	print(n)
for i in range(1, n + 1):
	idx = 0
	b = []
	for j in range(n):
		if a[j] == i:
			idx = j
			break
	if (c ^ i) & 1:
		for j in (i - 1) * [1] + [idx - i + 2, n - idx - 1]:
			if j:
				b.append(j)
		if len(b) == 1:
			continue
		a = a[idx + 1:] + a[i - 1:idx + 1] + a[:i - 1][::-1]
	else:
		for j in [idx, n - i - idx + 1] + (i - 1) * [1]:
			if j:
				b.append(j)
		if len(b) == 1:
			continue
		a = a[n - 1:n - i:-1] + a[idx:n - i + 1] + a[:idx]
	print(len(b), *b)


def solve(a):
	n = len(a)
	target = list(range(n))
	a = list(map(lambda x: x - 1, a))
	res = []
	while a != target:
		for i in range(n):
			for j in range(i, n):
				if a[i] == a[j] + 1:
					_i = i
					_j = j
					break
		(i, j) = (_i, _j)
		t = i
		while a[t] < a[t + 1]:
			t += 1
		a1 = a[:i]
		a2 = a[i:t + 1]
		a3 = a[t + 1:j + 1]
		a4 = a[j + 1:]
		a = a4 + a3 + a2 + a1
		cur = [len(a1), len(a2), len(a3), len(a4)]
		res += [cur]
	return res
n = int(input())
a = map(int, input().split())
a = list(a)
res = solve(a)
print(len(res))
for v in res:
	v = list(filter(lambda x: x > 0, v))
	v = [len(v)] + v
	print(' '.join(map(str, v)))


n = int(input())
a = list(map(int, input().split()))
operations = []
while a != sorted(a):
	s = set()
	ind_l = 0
	ind_r = 0
	for i in range(len(a)):
		if a[i] != 1 and a[i] - 1 not in s:
			ind_l = i
			ind_r = i + 1
			while a[ind_r] == a[ind_r - 1] + 1:
				ind_r += 1
			break
		s.add(a[i])
	ind2 = a.index(a[ind_l] - 1)
	ans = [ind_l, ind_r - ind_l, ind2 + 1 - ind_r, len(a) - ind2 - 1]
	for i in reversed(range(4)):
		if ans[i] == 0:
			ans.pop(i)
	operations.append(ans)
	a = a[ind2 + 1:] + a[ind_r:ind2 + 1] + a[ind_l:ind_r] + a[0:ind_l]
print(len(operations))
for elem in operations:
	print(len(elem), *elem)


n = int(input())
d = [int(i) for i in input().split()]

def process(it, tar):
	res = []
	kk = 0
	assert sum(tar) == len(it)
	for k in tar:
		res = it[kk:kk + k] + res
		kk += k
	assert len(res) == len(it)
	return res
t = list(range(1, n + 1))
r = []
while d != t:
	z = [0] * (n + 1)
	for i in range(n):
		z[d[i]] = i + 1
		if d[i] != 1 and z[d[i] - 1] == 0:
			j = [k for k in range(n) if d[k] == d[i] - 1][0]
			kk = 0
			while i + kk + 1 < n and d[i + kk + 1] == d[i] + kk + 1:
				kk += 1
			jj = 0
			while j - jj - 1 >= 0 and d[j - jj - 1] == d[j] - jj - 1:
				jj += 1
			tar = ([i] if i else []) + [kk + 1] + [n - i - kk - 1 - jj - 1 - (n - 1 - j) + jj + 1] + ([n - 1 - j] if j < n - 1 else [])
			tar = [k for k in tar if k]
			d = process(d, tar)
			r += [tar]
			break
print(len(r))
for k in r:
	print(len(k), *k)


import sys
import math
from decimal import *

def I():
	return int(sys.stdin.readline())

def IL():
	return list(map(int, sys.stdin.readline().strip().split()))

def ILS():
	return list(map(str, sys.stdin.readline().strip().split()))

def check(l):
	res = []
	for ll in l:
		res.extend(ll)
	cnt = 1
	for ll in res:
		if cnt != ll:
			return (ll, False)
		cnt += 1
	return (-1, True)

def get(l, no):
	cnt = 0
	for ll in l:
		if no in ll:
			return cnt
		cnt += 1

def group(l):
	res = []
	i = 0
	while i < len(l):
		val = l[i]
		j = i + 1
		while j < len(l):
			nxt = l[j][0]
			prev = val[-1]
			if prev + 1 == nxt:
				val.extend(l[j])
				j += 1
			else:
				break
		res.append(val)
		i = j
	return res

def solve():
	n = I()
	l = IL()
	ll = [[x] for x in l]
	ll = group(ll)
	res = []
	while True:
		(no, cor) = check(ll)
		if cor:
			break
		sno = get(ll, no)
		ono = get(ll, no - 1)
		cur = []
		i = 0
		while i < len(ll):
			if i == sno:
				val = []
				j = i
				while j < ono:
					val.append(ll[j])
					j += 1
				cur.append(val)
				i = j
			else:
				cur.append([ll[i]])
				i += 1
		point = []
		for cc in cur:
			cnt = 0
			for cxc in cc:
				cnt += len(cxc)
			point.append(cnt)
		ncur = cur[::-1]
		fcur = []
		for nnc in ncur:
			fcur.extend(nnc)
		ll = group(fcur)
		res.append(point)
		pass
	print(len(res))
	for rr in res:
		print(len(rr), end=' ')
		for xr in rr:
			print(xr, end=' ')
		print()
solve()


n = int(input())
l = list(map(int, input().split()))

def so(x):
	for i in range(n - 1):
		if l[i + 1] < l[i]:
			return False
	return True
op = 0
odp = []
while not so(l):
	if op % 2 == 0:
		chuj = 0
		for i in range(n):
			if l[i] == op + 1:
				chuj = i
		nowa = [chuj, n - chuj - op] + [1] * op
		if chuj == 0:
			nowa.pop(0)
		if n - chuj - op == 0:
			nowa.pop(1)
		odp.append(nowa)
		dupa = [0]
		for i in nowa:
			dupa.append(dupa[-1] + i)
		podz = []
		k = len(dupa)
		for i in range(k - 1):
			podz.append(l[dupa[i]:dupa[i + 1]])
		dup = []
		podz.reverse()
		for i in podz:
			dup += i
		l = dup
	else:
		chuj = 0
		for i in range(n):
			if l[i] == op + 1:
				chuj = i
		if chuj < n - 1:
			nowa = [1] * op + [chuj - op + 1, n - chuj - 1]
		else:
			nowa = [1] * op + [chuj - op + 1]
		odp.append(nowa)
		dupa = [0]
		for i in nowa:
			dupa.append(dupa[-1] + i)
		podz = []
		k = len(dupa)
		for i in range(k - 1):
			podz.append(l[dupa[i]:dupa[i + 1]])
		dup = []
		podz.reverse()
		for i in podz:
			dup += i
		l = dup
	op += 1
odpp = []
for i in odp:
	if len(i) > 1:
		odpp.append(i)
print(len(odpp))
for i in odpp:
	print(len(i), *i)


from collections import *
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def st():
	return input().rstrip('\n')

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())
t = 1
while t:
	t -= 1
	n = inp()
	a = lis()
	res = []
	while 1:
		(pointer1, pointer2) = (-1, -1)
		for i in range(n):
			for j in range(i + 1, n):
				if a[j] + 1 == a[i]:
					pointer1 = i
					pointer2 = j
					break
			if pointer1 != -1:
				break
		part1 = a[:pointer1]
		pointer3 = pointer1 + 1
		while pointer3 < pointer2 and a[pointer3] == a[pointer3 - 1] + 1:
			pointer3 += 1
		part2 = a[pointer1:pointer3]
		part3 = a[pointer3:pointer2 + 1]
		part4 = a[pointer2 + 1:]
		li = []
		if pointer1 == -1:
			break
		if part1:
			li.append(len(part1))
		if part2:
			li.append(len(part2))
		if part3:
			li.append(len(part3))
		if part4:
			li.append(len(part4))
		a = part4 + part3 + part2 + part1
		res.append(li)
	print(len(res))
	for i in res:
		print(len(i), *i)


from sys import stdin
input = stdin.readline

def A():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		if sum(a) == 0:
			print('NO')
		elif sum(a) > 0:
			a.sort(reverse=True)
			print('YES')
			print(*a)
		else:
			a.sort()
			print('YES')
			print(*a)

def B():
	from collections import deque
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		s = [bool(ord(x) - ord('L')) for x in input().rstrip()]
		lastGame = False
		score = 0
		for i in range(n):
			if s[i]:
				if lastGame:
					score += 2
				else:
					score += 1
				lastGame = True
			else:
				lastGame = False
		startW = 0
		endW = n - 1
		while startW < n and (not s[startW]):
			startW += 1
		while endW >= 0 and (not s[endW]):
			endW -= 1
		streak = 0
		wlws = deque()
		for i in range(startW + 1, endW + 1):
			if s[i] and streak > 0:
				wlws.append(streak)
				streak = 0
			elif not s[i]:
				streak += 1
		wlws = sorted(list(wlws))
		j = 0
		while j < len(wlws) and k >= wlws[j]:
			score += 2 * wlws[j] + 1
			k -= wlws[j]
			j += 1
		if k > 0:
			remainingLs = startW + (n - 1 - endW)
			if startW == n:
				remainingLs = n
				score -= 1
			if j < len(wlws):
				remainingLs = wlws[j]
			score += min(remainingLs, k) * 2
		print(score)

def C():
	(r, n) = map(int, input().split())
	xs = [0] * n
	ys = [0] * n
	ts = [0] * n
	tots = [0] * n
	for i in range(n):
		(ts[i], xs[i], ys[i]) = map(int, input().split())
	for i in range(n - 1, -1, -1):
		j = i + 1
		while j < n and ts[j] - ts[i] <= 4 * r:
			if abs(xs[j] - xs[i]) + abs(ys[j] - ys[i]) <= ts[j] - ts[i]:
				tots[i] = max(tots[j], tots[i])
			j += 1
		if xs[i] - 1 + ys[i] - 1 <= ts[i]:
			tots[i] += 1
		else:
			tots[i] = 0
	print(max(tots))

def D():
	n = int(input())
	c = list(map(int, input().split()))

	def transform(parts, c):
		h = []
		i = 0
		for part in parts:
			h.append(c[i:i + part])
			i += part
		c.clear()
		for j in range(len(h) - 1, -1, -1):
			c += h[j]
		return c
	if c == [1] or c == sorted(c):
		print(0)
		return
	transforms = [[] for i in range(52)]
	targetInd = c.index(1)
	if targetInd != 0:
		transforms[0] = [2, targetInd, n - targetInd]
		c = transform([targetInd, n - targetInd], c)
		transIndex = 1
	else:
		transIndex = 0
	currTrans = []
	numSorted = 1
	targetNum = 2
	inverted = False
	while c != sorted(c):
		if not inverted:
			k = c.index(targetNum) + 1 - numSorted
			leftOver = n - numSorted - k
			if leftOver != 0:
				currTrans = [1] * numSorted + [k] + [leftOver]
			else:
				currTrans = [1] * numSorted + [k]
		else:
			k = n - numSorted - c.index(targetNum)
			leftOver = n - numSorted - k
			if leftOver != 0:
				currTrans = [leftOver] + [k] + [1] * numSorted
			else:
				currTrans = [k] + [1] * numSorted
		c = transform(currTrans, c)
		numSorted += 1
		targetNum += 1
		inverted = not inverted
		transforms[transIndex] = [len(currTrans)] + currTrans
		transIndex += 1
	print(transIndex)
	for i in range(transIndex):
		print(*transforms[i])
D()


n = int(input())
arr = list(map(int, input().split()))
count = 0
mess = ''
midL = n // 2
midH = n // 2
while not all((arr[i] < arr[i + 1] for i in range(n - 1))):
	count += 1
	k = 1
	cur = 0
	lingid = []
	mgot = False
	s = 0
	nmidL = midL
	nmidH = midH
	for i in range(n):
		if not mgot and arr[i] == midH + 1:
			if i:
				lingid.append(i)
			s += i
			nmidH += 1
		if arr[i] == midL:
			mgot = True
			if len(lingid) == 0 and i:
				lingid.append(i)
			elif i - s:
				lingid.append(i - s)
			s = i
		if arr[i] == midH and i + 1 - s:
			lingid.append(i + 1 - s)
			s = i + 1
		if mgot and arr[i] == midL - 1:
			if i + 1 - s:
				lingid.append(i + 1 - s)
			s = i + 1
			nmidL -= 1
	midH = nmidH
	midL = nmidL
	if n - s:
		lingid.append(n - s)
	k = len(lingid)
	if k == 1:
		break
	else:
		mess += '\n' + str(k) + ' '
		for i in lingid:
			mess += str(i) + ' '
	sum = 0
	new = []
	for i in lingid:
		eel = sum
		sum += i
		new = arr[eel:sum] + new
	arr = new
print(count, end='')
print(mess)


n = int(input())
(*arr,) = map(int, input().split())
orig_arr = arr.copy()
operations = []
left = bool(n % 2)
sorted_len = 0

def apply(arr, op):
	new_arr = []
	offset = 0
	for dist in op:
		new_arr = arr[offset:offset + dist] + new_arr
		offset += dist
	return new_arr
for i in range(1, n + 1):
	idx = arr.index(i)
	if left:
		operations.append([idx] + [n - idx - sorted_len] + [1] * sorted_len)
	else:
		sorted_start = n - sorted_len
		operations.append([1] * sorted_len + [idx - sorted_len + 1] + [n - idx - 1])
	sorted_len += 1
	arr = apply(arr, operations[-1])
	if sorted(arr) == arr:
		break
	left = not left
assert sorted(orig_arr) == arr
new_ops = []
for op in operations:
	op = [v for v in op if v]
	if len(op) > 1:
		new_ops.append(op)
print(len(new_ops))
for op in new_ops:
	assert sum(op) == n
	print(len(op), end=' ')
	print(*op)


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, C):
	target = list(range(1, N + 1))
	ops = []
	while C != target:
		for i in range(1, N):
			j = i + 1
			ii = C.index(i)
			jj = C.index(j)
			if ii + 1 == jj:
				continue
			if jj < ii:
				k = 1
				while jj + k < N and C[jj + k - 1] + 1 == C[jj + k]:
					k += 1
				groups = [C[:jj], C[jj:jj + k], C[jj + k:ii + 1], C[ii + 1:]]
				ops.append([len(group) for group in groups if group])
				C = []
				for group in reversed(groups):
					C.extend(group)
	assert len(ops) <= N
	return str(len(ops)) + '\n' + '\n'.join((str(len(op)) + ' ' + ' '.join(map(str, op)) for op in ops))
DEBUG = False
if DEBUG:
	import random
	random.seed(0)
	for _ in range(100):
		N = random.randint(1, 52)
		C = list(range(1, N + 1))
		random.shuffle(C)
		print('tc', _, N, C)
		ans1 = solve(N, C)
	exit()
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(N,) = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
ans = solve(N, C)
print(ans)


def f(A, Ans):
	if len(A) > 2:
		z = True
		for i in range(len(A)):
			for j in range(i):
				if A[i][0] + 1 == A[j][0]:
					z = False
					Ans.append([])
					for k in range(j + 1):
						Ans[-1].append(A[k][1])
					Ans[-1].append(0)
					for k in range(j + 1, i + 1):
						Ans[-1][-1] += A[k][1]
					for k in range(i + 1, len(A)):
						Ans[-1].append(A[k][1])
					i0 = int(i)
					j0 = int(j)
					break
			if not z:
				break
		B0 = []
		for i in range(len(A) - 1, i0, -1):
			if A[i][0] > A[i0][0]:
				B0.append([A[i][0] - 1, A[i][1]])
			else:
				B0.append(A[i])
		for i in range(j0 + 1, i0):
			if A[i][0] > A[i0][0]:
				B0.append([A[i][0] - 1, A[i][1]])
			else:
				B0.append(A[i])
		B0.append([A[i0][0], A[j0][1] + A[i0][1]])
		for i in range(j0 - 1, -1, -1):
			if A[i][0] > A[i0][0]:
				B0.append([A[i][0] - 1, A[i][1]])
			else:
				B0.append(A[i])
		if len(B0) > 100:
			print(0 / 0)
		if sorted(B0) == B0:
			return Ans
		else:
			Ans = f(B0, Ans)
			return Ans
	else:
		Ans.append([A[0][1], A[1][1]])
		return Ans
n = int(input())
A = list(map(int, input().split()))
if A == sorted(A):
	print(0)
else:
	for i in range(len(A)):
		A[i] = [A[i], 1]
	ANS = f(A, [])
	print(len(ANS))
	for ans in ANS:
		print(len(ans), end=' ')
		print(*ans)


ans = []

def adjust(pack):
	np = []
	for i in pack:
		if i:
			np += [i]
	return np

def flip(deck, packs):
	nd = []
	s = len(deck)
	for i in packs[::-1]:
		if i == 0:
			continue
		s -= i
		nd += deck[s:s + i]
	return nd
n = int(input())
d = list(map(int, input().split()))
if n == 1:
	print(0)
	exit()
one = d.index(1)
nth = d.index(n)
fir = min(one, nth)
sec = max(one, nth)
packs = [fir + 1, sec - fir - 1, n - sec]
d = flip(d, packs)
ans += [adjust(packs)]
pat = 2
while pat < n:
	ind = d.index(pat)
	if d[0] == 1:
		packs = []
		for i in range(pat - 1):
			packs.append(1)
		packs.append(ind + 1 - pat + 1)
		packs.append(n - 1 - ind - 1)
		packs.append(1)
		d = flip(d, packs)
		ans += [adjust(packs)]
	else:
		packs = []
		packs.append(1)
		packs.append(ind - 1)
		packs.append(n - ind - pat + 1)
		for i in range(pat - 1):
			packs.append(1)
		d = flip(d, packs)
		ans += [adjust(packs)]
	pat += 1
if d[0] != 1:
	flip(d, [1] * n)
	ans += [[1] * n]
print(len(ans))
for shuf in ans:
	ns = [len(shuf)] + shuf
	ns = [str(i) for i in ns]
	print(' '.join(ns))


pocet = int(input())
d = list(map(int, input().split(' ')))
if pocet == 1:
	print('0')
else:
	rev = False
	n = 0
	res = []
	for i in range(pocet - 1):
		ind = d.index(i + 1)
		ind2 = d.index(i + 2)
		if ind != ind2 - 1:
			n += 1
			if ind > ind2:
				doc = []
				if ind2 > 0:
					doc.append(str(ind2))
				if rev:
					doc.append(str(ind - ind2))
					doc.append(str(1))
					doc.append(str(i))
					if ind + i < pocet - 1:
						doc.append(str(pocet - 1 - ind - i))
				else:
					doc.append(str(ind - i - ind2))
					doc.append(str(i + 1))
					if ind < pocet - 1:
						doc.append(str(pocet - 1 - ind))
				res.append(doc)
				rev = False
			else:
				doc = []
				if rev:
					if ind > 0:
						doc.append(str(ind))
					doc.append(str(1))
					doc.append(str(i))
					doc.append(str(ind2 - ind - i))
				else:
					if ind > i:
						doc.append(str(ind - i))
					doc.append(str(i + ind2 - ind))
					doc.append(str(1))
				if ind2 < pocet - 1:
					doc.append(str(pocet - 1 - ind2))
				res.append(doc)
				rev = True
			docd = []
			inde = 0
			for j in reversed(range(len(doc))):
				for k in range(int(doc[j])):
					docd.append(d[len(d) - int(doc[j]) + k - inde])
				inde += int(doc[j])
			d = docd
	if d.index(pocet) == 0:
		res.append(['1', str(pocet - 1)])
		n += 1
	print(n)
	for re in res:
		print(len(re), end=' ')
		print(' '.join(re))


n = int(input())

def sf(a, d):
	s = [0]
	for di in d:
		s.append(s[-1] + di)
	rv = []
	for i in range(len(d) - 1, -1, -1):
		rv += a[s[i]:s[i + 1]]
	return rv
c = list(map(int, input().split()))
ans = []
while True:
	for i in range(n):
		if c[i] != i + 1:
			break
	else:
		break
	for k in range(i, n):
		if c[k] + 1 != c[k + 1]:
			break
	s = c[i]
	for j in range(k + 1, n):
		if c[j] == s - 1:
			break
	t = [i, k - i + 1, j - k, n - (i + k - i + 1 + j - k)]
	t = list(filter(lambda x: x != 0, t))
	ans.append(t)
	c = sf(c, ans[-1])
print(len(ans))
for a in ans:
	print(len(a), *a)


import sys
input = sys.stdin.buffer.readline
n = int(input())
cl = list(map(int, input().split()))

def apply(cl, d):
	ls = []
	for u in reversed(d):
		for v in cl[-u:]:
			ls.append(v)
		for _ in range(u):
			cl.pop()
	return ls
res = []
for u in range(n - 1, 0, -1):
	(l, r) = (cl.index(u + 1), cl.index(n))
	if l <= r:
		(l, r, inc) = (l, r + 1, 1)
	else:
		(l, r, inc) = (r, l + 1, 0)
	p = cl.index(u)
	if inc and p < l:
		d = [p - 0, l - p] + [1] * (r - l) + [n - r]
	elif inc and p >= r:
		d = [l, r - l, p + 1 - r, n - (p + 1)]
	elif not inc and p < l:
		d = [p, l - p, r - l, n - r]
	else:
		d = [l] + [1] * (r - l) + [p + 1 - r, n - (p + 1)]
	d = [u for u in d if u > 0]
	cl = apply(cl, d)
	res.append(d)
if cl[0] != 1:
	res.append([1] * n)
print(len(res))
for d in res:
	print(*[len(d)] + d)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
n = N()
a = RLL()
count = 0
res = []
while 1:
	first = 1
	for i in range(1, n):
		if a[i] == a[i - 1] + 1 or (a[i - 1] == n and a[i] == 1):
			first += 1
		else:
			break
	if first == n:
		if a[0] != 1:
			count += 1
			t = a.index(1)
			res.append([2, t, n - t])
		break
	count += 1
	if a[0] == 1:
		key = n
	else:
		key = a[0] - 1
	t = a.index(key)
	if t == n - 1:
		res.append([2, first, n - first])
		a = a[first:] + a[:first]
	else:
		res.append([3, first, t + 1 - first, n - t - 1])
		a = a[t + 1:] + a[first:t + 1] + a[:first]
print(count)
for r in res:
	print_list(r)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if not True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	while a != sorted(a):
		for i in range(n):
			if a[i] == n:
				continue
			(x, y) = (i, a.index(a[i] + 1))
			if y > x:
				continue
			while x > 0 and a[x - 1] == a[x] - 1:
				x -= 1
			chosen = [y, x, i + 1]
			if n not in chosen:
				chosen += [n]
			if 0 not in chosen:
				chosen += [0]
			chosen = sorted(chosen)
			c = []
			for i in range(1, len(chosen)):
				c += [chosen[i] - chosen[i - 1]]
			ans += [[len(c)] + c]
			b = []
			for j in range(len(chosen) - 2, -1, -1):
				for k in range(chosen[j], chosen[j + 1]):
					b += [a[k]]
			a = list(b)
			break
	print(len(ans))
	for each in ans:
		print(*each)


n = int(input())
c = [int(x) for x in input().split()]
ops = []
correct_side = c[0] == 1
touched = False

def make_selection(selection):
	global correct_side, c
	selection = sorted((x for x in selection if x[0] <= x[1]))
	if len(selection) == 1:
		return
	ops.append(selection)
	p = []
	for (b, e) in reversed(selection):
		p += c[b:e + 1]
	c = p
	correct_side = c[0] == 1
for i in range(1, n + 1):
	selection = []
	for j in range(1, i):
		if correct_side:
			selection.append((j - 1, j - 1))
		else:
			selection.append((n - j, n - j))
	found = c.index(i)
	if correct_side and found == i - 1 or (not correct_side and found == n - i):
		continue
	if correct_side:
		selection.append((i - 1, found))
		selection.append((found + 1, n - 1))
	else:
		selection.append((0, found - 1))
		selection.append((found, n - i))
	make_selection(selection)
if not correct_side:
	make_selection([(x, x) for x in range(0, n)])
print(len(ops))
for selection in ops:
	print(len(selection), end=' ')
	for (b, e) in selection:
		print(e - b + 1, end=' ')
	print()


import sys
import math
from collections import defaultdict, Counter
n = int(input())
a = list(map(int, input().split()))
d = [0] * (n + 1)
tot = 0
a1 = sorted(a)
l = []
for i in range(n):
	d[a[i]] = i
while a != a1:
	for i in range(2, n + 1):
		if d[i] < d[i - 1]:
			ind = d[i - 1]
			while a[ind] > a[ind - 1]:
				ind -= 1
			tot += 1
			c = 0
			cur = []
			a = a[d[i - 1] + 1:] + a[ind:d[i - 1] + 1] + a[d[i]:ind] + a[:d[i]]
			if len(a[:d[i]]) > 0:
				c += 1
				cur.append(len(a[:d[i]]))
			if len(a[d[i]:ind]) > 0:
				c += 1
				cur.append(len(a[d[i]:ind]))
			if len(a[ind:d[i - 1] + 1]) > 0:
				c += 1
				cur.append(len(a[ind:d[i - 1] + 1]))
			if len(a[d[i - 1] + 1:]) > 0:
				c += 1
				cur.append(len(a[d[i - 1] + 1:]))
			for i in range(n):
				d[a[i]] = i
			cur = [c] + cur
			l.append(cur)
print(tot)
for i in l:
	print(*i)


n = int(input())
a = list(map(int, input().split()))

def find(a):
	for i in range(n - 1):
		for j in range(i + 1, n):
			if a[i] == a[j] + 1:
				return (i, j)
	return (-1, -1)

def get(arr):
	length = []
	for x in arr:
		if len(x) > 0:
			length.append(str(len(x)))
	return length
arr = []
while True:
	(i, j) = find(a)
	if i == -1:
		break
	idx1 = i
	while idx1 + 1 <= n - 1 and a[idx1 + 1] == a[idx1] + 1:
		idx1 += 1
	arr.append(get([a[:i], a[i:idx1 + 1], a[idx1 + 1:j + 1], a[j + 1:]]))
	a = a[j + 1:] + a[idx1 + 1:j + 1] + a[i:idx1 + 1] + a[:i]
print(len(arr))
for x in arr:
	print(' '.join([str(len(x))] + x))


n = int(input())
c = [int(c) for c in input().split()]
ans = []
while c != sorted(c):
	cuts = []
	l = 0
	if c[0] == 1:
		while c[l] == l + 1:
			l += 1
		cuts.append((0, l))
	r = l + 1
	while c[r] == c[l] + r - l:
		r += 1
	cuts.append((l, r))
	l = cuts[-1][0]
	while c[r] != c[l] - 1:
		r += 1
	r += 1
	cuts.append((cuts[-1][1], r))
	if r < n:
		cuts.append((r, n))
	nc = []
	ans.append([])
	for cut in reversed(cuts):
		nc += c[cut[0]:cut[1]]
		ans[-1].append(len(c[cut[0]:cut[1]]))
	ans[-1] = list(reversed(ans[-1]))
	c = nc
assert len(ans) <= n
print(len(ans))
for op in ans:
	print(str(len(op)), ' '.join(map(str, op)))


n = int(input())
t = 0
a = list(map(int, input().split()))
d = []
for i in range(n - 1):
	if a[i] != i + 1 and t == 0 or (a[n - i - 1] != i + 1 and t == 1):
		for j in range(n):
			if a[j] == i + 1:
				k = j
				break
		if t == 0:
			b = a[:i][::-1]
			c = a[i:k + 1]
			e = a[k + 1:]
			y = i + 2
			if len(e) == 0:
				y -= 1
			u = [y]
			for j in range(i):
				u.append(1)
			u.append(len(c))
			if len(e) > 0:
				u.append(len(e))
			d.append(u)
			a = []
			for x in e:
				a.append(x)
			for x in c:
				a.append(x)
			for x in b:
				a.append(x)
		else:
			b = a[n - i:][::-1]
			c = a[k:n - i]
			e = a[:k]
			a = []
			for x in b:
				a.append(x)
			for x in c:
				a.append(x)
			for x in e:
				a.append(x)
			y = i + 2
			if len(e) == 0:
				y -= 1
			u = [y]
			if len(e) > 0:
				u.append(len(e))
			u.append(len(c))
			for j in range(len(b)):
				u.append(1)
			d.append(u)
		t = (t + 1) % 2
if t == 1:
	u = [1] * (n + 1)
	u[0] = n
	d.append(u)
f = 0
for x in d:
	if x[0] > 1:
		f += 1
print(f)
for x in d:
	if x[0] > 1:
		print(*x)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10)]
pp = [0] * 10

def SieveOfEratosthenes(n=10):
	p = 2
	c = 0
	while p * p <= n:
		if prime[p] == True:
			c += 1
			for i in range(p, n + 1, p):
				pp[i] += 1
				prime[i] = False
		p += 1

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = arr[n - 1]
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] >= key:
			res = arr[mid]
			right = mid - 1
		else:
			left = mid + 1
	return res

def binarySearch1(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = arr[0]
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] > key:
			right = mid - 1
		else:
			res = arr[mid]
			left = mid + 1
	return res

def split(a1, d):
	b = []
	for i in d:
		for j in range(i - 1, -1, -1):
			b = [a1[j]] + b
		a1 = a1[i:]
	return b
n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print(0)
	sys.exit(0)
res = []
mid = (n + 1) // 2
if a[-1] != mid:
	ind = 0
	for j in range(n):
		if a[j] == mid:
			ind = j + 1
			break
	a = split(a, [ind, n - ind])
	res.append([ind, n - ind])
nxt1 = mid + 1
nxt2 = mid - 1
for i in range(n - 1):
	c = i + 1
	if i % 2 == 0:
		ind = 0
		for i in range(n):
			if a[i] == nxt1:
				ind = i
				break
		p = []
		if ind != 0:
			p = [ind]
		p.append(n - c - ind)
		p.append(c)
		a = split(a, p)
		nxt1 += 1
		res.append(p)
	else:
		ind = 0
		for i in range(n):
			if a[i] == nxt2:
				ind = i + 1
				break
		p = [c]
		p.append(ind - c)
		if ind != n:
			p.append(n - ind)
		a = split(a, p)
		nxt2 -= 1
		res.append(p)
print(len(res))
for i in res:
	print(len(i), *i)


n = int(input())
a = [int(x) for x in input().split()]
ans = []
for j in range(1, n):
	for i in range(1, n):
		x = a.index(i)
		y = a.index(i + 1)
		if x < y:
			continue
		s1 = a[:y]
		z = y + 1
		while z < x and a[z] == a[z - 1] + 1:
			z += 1
		s2 = a[y:z]
		s3 = a[z:x + 1]
		s4 = a[x + 1:n]
		a = s4 + s3 + s2 + s1
		ans.append([len(s1), len(s2), len(s3), len(s4)])
assert len(ans) <= n
assert a == list(range(1, n + 1))
print(len(ans))
for z in ans:
	z = [x for x in z if x]
	print(len(z), ' '.join((str(x) for x in z)))


import math
import os
from io import BytesIO, IOBase
import sys
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import copy
import random

def make_move(a, move):
	b = []
	last = 0
	for i in move:
		b = a[last:last + i] + b
		last = last + i
	return b
n = int(input())
a = [int(i) for i in input().split()]
a_sorted = copy.deepcopy(a)
a_sorted.sort()
moves = []
for (idx, val) in enumerate(a_sorted):
	if a == a_sorted:
		break
	if idx % 2 == 0:
		found_idx = a.index(val, idx)
		moves.append([1 for x in range(0, idx)] + [found_idx - idx + 1, n - found_idx - 1])
	else:
		found_idx = a.index(val, 0, len(a) - idx + 1)
		moves.append([found_idx, n - idx - found_idx] + [1 for x in range(0, idx)])
	a = make_move(a, moves[-1])
to_remove = []
for idx in range(len(moves)):
	while True:
		try:
			moves[idx].remove(0)
		except:
			break
	if len(moves[idx]) <= 1:
		to_remove.append(idx)
to_remove.sort(reverse=True)
for idx in to_remove:
	moves.pop(idx)
print(len(moves))
for idx in range(len(moves)):
	sys.stdout.write(str(len(moves[idx])) + ' ')
	sys.stdout.write(' '.join([str(x) for x in moves[idx]]))
	sys.stdout.write('\n')


import os
import sys
from io import BytesIO, IOBase

def operation(c, q):
	NewC = []
	cnt = 0
	for elem in q:
		NewC.append(c[cnt:cnt + elem])
		cnt += elem
	NewC.reverse()
	c.clear()
	for l in NewC:
		c += l

def main():
	n = int(input())
	c = list(map(int, input().split()))
	ans = []
	forwardOrBackward = 0
	for i in range(n - 1):
		locCur = -1
		for j in range(n):
			if c[j] == i + 1:
				locCur = j
				break
		if forwardOrBackward == 0:
			q = []
			q += [1] * locCur
			q.append(n - i - locCur)
			q += [1] * i
			if len(q) != 1:
				ans.append(tuple(q))
			operation(c, q)
			forwardOrBackward = 1
		else:
			q = []
			q += [1] * i
			q.append(locCur - i + 1)
			q += [1] * (n - locCur - 1)
			if len(q) != 1:
				ans.append(tuple(q))
			operation(c, q)
			forwardOrBackward = 0
	if c[0] != 1:
		ans.append(tuple([1] * n))
	print(len(ans))
	for tup in ans:
		print(str(len(tup)) + ' ' + ' '.join(map(str, tup)))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin
n = int(stdin.readline().strip())
s = list(map(int, stdin.readline().strip().split()))
s1 = s.copy()
s1.sort()
ans = 0
res = []
while s != s1:
	ans += 1
	aux = []
	last = 0
	t = False
	for i in range(n):
		for j in range(i + 1, n):
			if s[i] == s[j] + 1:
				ind = 0
				for q in range(j - 1, -1, -1):
					if s[q] + 1 != s[q + 1]:
						ind = q + 1
						break
				aux = [s[0:i], s[i:ind], s[ind:j + 1], s[j + 1:]]
				t = True
				break
		if t:
			break
	if not t:
		break
	aux = aux[::-1]
	s = []
	res1 = []
	for i in aux:
		if len(i) > 0:
			res1.append(len(i))
		for j in i:
			s.append(j)
	res.append(res1[::-1].copy())
print(len(res))
for i in res:
	print(len(i), *i)


import sys
input = sys.stdin.readline
n = int(input())
ar = list(map(int, input().split()))
br = ar.copy()
br.sort()
typ = 'r'
res = 0
count = 0
ans = []
while ar != br:
	tem = []
	xx = []
	if typ == 'r':
		for i in range(1, res + 1):
			tem.append(i)
		ne = res + 1
		for i in range(ne, n + 1):
			if ar[-i] == ne:
				break
		siz = i - ne + 1
		for ii in range(n - i, n - ne + 1):
			tem.append(ar[ii])
		for ii in range(n - i):
			tem.append(ar[ii])
		xx = [n - res - siz, siz] + [1] * res
		typ = 'f'
	else:
		tem = []
		ne = res + 1
		xx = [1] * res
		for i in range(ne - 1, n):
			if ar[i] == ne:
				break
		p2 = []
		p3 = []
		for ii in range(ne - 1, i + 1):
			p2.append(ar[ii])
		for ii in range(i + 1, n):
			p3.append(ar[ii])
		xx.append(len(p2))
		xx.append(len(p3))
		tem = p3.copy() + p2.copy()
		for i in range(res, 0, -1):
			tem.append(i)
		typ = 'r'
	res += 1
	if ar != tem:
		count += 1
		ar = tem.copy()
		ans.append([])
		for i in xx:
			if i != 0:
				ans[-1].append(i)
se = set({})
print(count)
for i in ans:
	print(len(i), *i)


def ope(li, ti):
	ans = []
	if ti % 2 == 0:
		tmp = []
		for a in range(len(li) - 1):
			tmp.append(li[a])
			if li[a] > li[a + 1]:
				ans.append(tmp)
				tmp = []
		tmp.append(li[a + 1])
		ans.append(tmp)
	else:
		tmp = []
		for a in range(len(li) - 1):
			tmp.append(li[a])
			if li[a] < li[a + 1]:
				ans.append(tmp)
				tmp = []
		tmp.append(li[a + 1])
		ans.append(tmp)
	ans = ans[::-1]
	fans = []
	q = len(ans)
	leng = []
	for a in ans:
		leng.append(len(a))
		fans += a
	return (fans, leng[::-1], q)
n = int(input())
dec = list(map(int, input().split()))
ans = sorted(dec)
tu = 0
if dec == ans:
	print(0)
	exit()
fans = []
while dec != ans:
	(dec, leng, q) = ope(dec, tu)
	fans.append([q] + leng)
	tu += 1
print(tu)
for a in range(tu):
	print(*fans[a])


def append0(arr, x):
	if x > 0:
		arr.append(x)

def unshuffle(n, arr):
	for i in range(n):
		arr[i] -= 1
	if n == 1:
		print(0)
		return
	res = []
	ind0 = arr.index(0)
	ind1 = arr.index(1)
	reversed = False
	for i in range(1, n):
		ind0 = arr.index(0)
		ind1 = arr.index(i)
		cur = []
		if not reversed:
			if ind1 > ind0 + i:
				append0(cur, ind0)
				cur.extend([1] * i)
				append0(cur, ind1 + 1 - ind0 - i)
				append0(cur, n - 1 - ind1)
				arr = arr[ind1 + 1:] + arr[ind0 + i:ind1 + 1] + list(range(i - 1, -1, -1)) + arr[:ind0]
				reversed = True
				res.append(cur)
			elif ind1 < ind0:
				append0(cur, ind1)
				append0(cur, ind0 - ind1)
				cur.append(i)
				append0(cur, n - i - ind0)
				arr = arr[ind0 + i:] + list(range(i)) + arr[ind1:ind0] + arr[:ind1]
				res.append(cur)
		elif ind0 < ind1:
			append0(cur, ind0 - i + 1)
			cur.append(i)
			append0(cur, ind1 - ind0)
			append0(cur, n - ind1 - 1)
			arr = arr[ind1 + 1:] + arr[ind0 + 1:ind1 + 1] + list(range(i - 1, -1, -1)) + arr[:ind0 - i + 1]
			res.append(cur)
		elif ind1 + i < ind0:
			append0(cur, ind1)
			append0(cur, ind0 - i + 1 - ind1)
			cur.extend([1] * i)
			append0(cur, n - ind0 - 1)
			arr = arr[ind0 + 1:] + list(range(i)) + arr[ind1:ind0 - i + 1] + arr[:ind1]
			reversed = False
			res.append(cur)
	if arr[0]:
		res.append([1] * n)
	print(len(res))
	for r in res:
		print(len(r), *r)
n = int(input())
arr = list(map(int, input().split()))
unshuffle(n, arr)