#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
int n;
struct block {
  vector<int> v;
  int id;
};
vector<block> b;
int a[maxn];
void get_blocks() {
  b.clear();
  block cur;
  int j = 1;
  while (j <= n) {
    cur.v.clear();
    while (1) {
      cur.v.push_back(a[j]);
      if (j == n || a[j + 1] != a[j] + 1) {
        ++j;
        break;
      }
      ++j;
    }
    b.push_back(cur);
  }
  vector<int> bv;
  for (auto& w : b) bv.push_back(w.v[0]);
  sort(bv.begin(), bv.end());
  for (auto& w : b) {
    int u = lower_bound(bv.begin(), bv.end(), w.v[0]) - bv.begin() + 1;
    w.id = u;
  }
}
vector<vector<int>> tv;
void tr() {
  vector<vector<block>> seq;
  int la = b.back().id;
  int en = b.size() - 1;
  vector<block> last;
  last.push_back(b.back());
  vector<int> e;
  vector<block> mid;
  if (la == b.size()) {
    la = b[b.size() - 2].id;
    vector<block> q;
    q.push_back(b[b.size() - 2]);
    --en;
    for (int i = 0; i < b.size(); ++i) {
      if (b[i].id == la + 1) {
        for (int j = i; j < en; ++j) mid.push_back(b[j]);
        vector<block> fr;
        for (int j = 0; j < i; ++j) fr.push_back(b[j]);
        if (fr.size()) seq.push_back(fr);
        seq.push_back(mid);
        seq.push_back(q);
        seq.push_back(last);
        break;
      }
    }
    goto N;
  }
  for (int i = 0; i < b.size(); ++i) {
    if (b[i].id == la + 1) {
      for (int j = i; j < en; ++j) mid.push_back(b[j]);
      vector<block> fr;
      for (int j = 0; j < i; ++j) fr.push_back(b[j]);
      if (fr.size()) seq.push_back(fr);
      seq.push_back(mid);
      seq.push_back(last);
      break;
    }
  }
N:;
  e.push_back(seq.size());
  for (auto& w : seq) {
    int cnt = 0;
    for (auto& bb : w) cnt += bb.v.size();
    e.push_back(cnt);
  }
  tv.push_back(e);
  reverse(seq.begin(), seq.end());
  int j = 1;
  for (auto& w : seq) {
    for (auto& ee : w) {
      for (auto& ii : ee.v) a[j++] = ii;
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  while (1) {
    get_blocks();
    if (b.size() == 1) break;
    tr();
  }
  cout << tv.size() << "\n";
  for (auto& w : tv) {
    for (int i = 0; i < w.size(); ++i) {
      cout << w[i];
      if (i < w.size() - 1)
        cout << " ";
      else
        cout << "\n";
    }
  }
}
