#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
int n, c[N], idx = -1;
vector<vector<int> > op;
vector<int> tmp;
void print() {
  cout << op.size() << endl;
  for (int i = 0; i < op.size(); ++i) {
    printf("%d", (int)op[i].size());
    for (int j = 0; j < op[i].size(); ++j) printf(" %d", op[i][j]);
    puts("");
  }
}
void perform(vector<int> &f) {
  if (tmp.size() == 1) {
    tmp.clear();
    return;
  }
  int sum = 0;
  for (int i = 0; i < f.size(); ++i) sum += f[i];
  assert(sum == n);
  vector<vector<int> > chg;
  int idx = 0;
  for (int i = 0; i < f.size(); ++i) {
    chg.push_back(vector<int>());
    for (int tt = 0; tt < f[i]; ++tt) chg.back().push_back(c[idx++]);
  }
  idx = 0;
  reverse(chg.begin(), chg.end());
  for (auto g : chg)
    for (auto k : g) c[idx++] = k;
  op.push_back(f);
  f.clear();
}
void psh(int block) {
  if (block > 0) tmp.push_back(block);
}
void opr(int sorted, bool isLeft) {
  int target = n - sorted;
  for (int i = 0; i < sorted; ++i) {
    psh(1);
  }
  int idxTarget = -1;
  for (int i = 0; i < n; ++i)
    if (c[i] == target) idxTarget = i;
  psh(isLeft ? idxTarget - sorted + 1 : (n - idxTarget) - sorted);
  psh(isLeft ? n - idxTarget - 1 : idxTarget);
  if (!isLeft) reverse(tmp.begin(), tmp.end());
  perform(tmp);
}
void debugPrint() {
  for (int i = 0; i < n; ++i) {
    printf("%d ", c[i]);
  }
  puts("");
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &c[i]);
    if (c[i] == n) idx = i;
  }
  psh(idx + (n % 2));
  psh(n - (idx + (n % 2)));
  perform(tmp);
  bool isLeft = !(n % 2);
  for (int sorted = 1; sorted < n; ++sorted) {
    opr(sorted, isLeft);
    isLeft = isLeft ^ 1;
  }
  print();
  return 0;
}
