#include <bits/stdc++.h>
using namespace std;
long long int arr[100004], vis[100004] = {0};
map<long long int, long long int> ind;
int ooo[100004] = {0};
vector<queue<int> > v;
int main() {
  int n;
  cin >> n;
  int i, j;
  map<int, int> mm;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    mm[arr[i]];
  }
  map<int, int>::iterator it;
  int oo = 0;
  for (it = mm.begin(); it != mm.end(); it++) {
    ind[it->first] = oo++;
  }
  for (i = 0; i < n; i++) {
    arr[i] = ind[arr[i]];
    ooo[arr[i]] = i;
  }
  for (i = 0; i < n; i++) {
    if (!vis[i]) {
      int p = i;
      queue<int> q;
      q.push(i);
      p = ooo[i];
      vis[i] = 1;
      while (p != i) {
        vis[p] = 1;
        q.push(p);
        p = ooo[p];
      }
      v.push_back(q);
    }
  }
  cout << v.size() << endl;
  for (i = 0; i < v.size(); i++) {
    cout << v[i].size() << " ";
    while (!v[i].empty()) {
      cout << v[i].front() + 1 << " ";
      v[i].pop();
    }
    cout << endl;
  }
  return 0;
}
