#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> A(n);
  vector<int> P(n + 1);
  for (auto &x : A) cin >> x;
  for (int i = 0; i < n; ++i) P[A[i]] = i;
  int cnt = 0;
  vector<vector<int>> sol;
  for (int kk = 0; kk < n; ++kk) {
    if (is_sorted(A.begin(), A.end())) break;
    ++cnt;
    int goal = -1;
    for (int i = 1; i <= n - 1; ++i) {
      if (P[i] > P[i + 1]) {
        goal = i;
        break;
      }
    }
    vector<vector<int>> G;
    G.push_back({});
    int state = 0;
    for (int i = 0; i < n; ++i) {
      if (state == 0) {
        if (A[i] != goal + 1) {
          G.back().push_back(A[i]);
        } else {
          G.push_back({A[i]});
          state = 1;
        }
      } else if (state == 1) {
        if (A[i] == goal) {
          G.push_back({A[i]});
          state = 3;
          G.push_back({});
        } else if (A[i] == A[i - 1] + 1)
          G.back().push_back(A[i]);
        else {
          G.push_back({A[i]});
          state = 2;
        }
      } else if (state == 2) {
        G.back().push_back(A[i]);
        if (A[i] == goal) {
          state = 3;
          G.push_back({});
        }
      } else {
        G.back().push_back(A[i]);
      }
    }
    sol.push_back({});
    for (auto &x : G) {
      if (!x.empty()) sol.back().push_back(x.size());
    }
    reverse(G.begin(), G.end());
    {
      int i = 0;
      for (auto &g : G)
        for (auto x : g) A[i++] = x;
    }
    for (int i = 0; i < n; ++i) P[A[i]] = i;
  }
  assert(is_sorted(A.begin(), A.end()));
  cout << cnt << '\n';
  for (auto &s : sol) {
    cout << s.size() << ' ';
    for (auto &x : s) cout << x << ' ';
    cout << '\n';
  }
  return 0;
}
