#include <bits/stdc++.h>
using namespace std;
struct par {
  int key;
  int pos;
  bool col;
  par() : col(1) {}
};
par A[100002];
vector<int> Stek, siz;
bool myfunc(const par& a, const par& b) { return (a.key < b.key); }
int main() {
  int n, res = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> A[i].key;
    A[i].pos = i;
  }
  sort(A + 1, A + n + 1, myfunc);
  for (int i = 1; i <= n; ++i) {
    int j = i, size = 0;
    while (A[j].col) {
      A[j].col = 0;
      size++;
      Stek.push_back(j);
      j = A[j].pos;
    }
    if (size) {
      res++;
      siz.push_back(size);
    }
  }
  cout << res << endl;
  int j = 0;
  for (int i = 0; i < res; ++i) {
    cout << siz[i] << " ";
    for (int k = 0; k < siz[i]; ++k) {
      cout << Stek[j] << " ";
      j++;
    }
    cout << endl;
  }
  return 0;
}
