#include <bits/stdc++.h>
using namespace std;
vector<int> a, Q;
vector<vector<int>> Q2;
int n;
void help(int x) {
  int p1, p2, p3, s1, s2, s3, s4;
  vector<int> A, B, C, D;
  p3 = find(a.begin(), a.end(), x) - a.begin();
  p1 = find(a.begin(), a.end(), x + 1) - a.begin() - 1;
  p2 = p3;
  while (a[p2] != x + 1) --p2;
  while (a[p2 + 1] == a[p2] + 1) ++p2;
  for (int i = 1; i <= p1; ++i) A.push_back(a[i]);
  for (int i = p1 + 1; i <= p2; ++i) B.push_back(a[i]);
  for (int i = p2 + 1; i <= p3; ++i) C.push_back(a[i]);
  for (int i = p3 + 1; i <= n; ++i) D.push_back(a[i]);
  int sz = (!A.empty()) + (!B.empty()) + (!C.empty()) + (!D.empty());
  if (sz) {
    Q.push_back(sz);
    vector<int> temp;
    if (!A.empty()) temp.push_back(A.size());
    if (!B.empty()) temp.push_back(B.size());
    if (!C.empty()) temp.push_back(C.size());
    if (!D.empty()) temp.push_back(D.size());
    Q2.push_back(temp);
  }
  vector<int> b{0};
  for (auto it : D) b.push_back(it);
  for (auto it : C) b.push_back(it);
  for (auto it : B) b.push_back(it);
  for (auto it : A) b.push_back(it);
  a = b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  a = vector<int>(n + 1);
  for (int i = 1; i <= n; ++i) cin >> a[i];
  while (1) {
    int no = 0;
    for (int j = 1; j < n; ++j) {
      if (find(a.begin(), a.end(), j + 1) < find(a.begin(), a.end(), j)) {
        no = j;
        break;
      }
    }
    if (!no) break;
    help(no);
  }
  cout << Q.size() << '\n';
  for (int i = 0; i < Q.size(); ++i, cout << '\n') {
    cout << Q[i] << ' ';
    for (auto it : Q2[i]) cout << it << ' ';
  }
}
