#include <bits/stdc++.h>
using namespace std;
int v[100100];
int u[100100];
bool sorted[100100];
int find(int lo, int hi, int val) {
  int mid;
  while (lo <= hi) {
    mid = (hi - lo) / 2 + lo;
    if (val < u[mid]) {
      hi = mid - 1;
    } else if (val > u[mid]) {
      lo = mid + 1;
    } else {
      return mid;
    }
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0, _ = n; i < _; i++) {
    cin >> v[i];
    u[i] = v[i];
  }
  sort(u, u + n);
  int i = 0, j = 0;
  set<int> s;
  vector<set<int> > subsequences;
  while (i < n) {
    if (sorted[j] && !s.empty()) {
      set<int> tmp(s.begin(), s.end());
      subsequences.push_back(tmp);
      s.clear();
    } else if (!sorted[j]) {
      sorted[j] = 1;
      s.insert(j);
      j = find(0, n - 1, v[j]);
    } else {
      j = ++i;
    }
  }
  cout << subsequences.size() << endl;
  for (int i = 0, _ = subsequences.size(); i < _; i++) {
    cout << subsequences[i].size();
    for (auto k : subsequences[i]) {
      cout << ' ' << k + 1;
    }
    cout << endl;
  }
}
