#include <bits/stdc++.h>
using namespace std;
int a[100005], s[100005];
bool vis[100005];
vector<vector<int>*> ans;
map<int, int> order;
int n;
int main(int argc, char* argv[]) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    s[i] = a[i];
  }
  sort(s, s + n);
  for (int i = 0; i < n; ++i) order[s[i]] = i;
  for (int i = 0; i < n; ++i) {
    if (!vis[i]) {
      vector<int>* seq = new vector<int>();
      int p = i;
      while (!vis[p]) {
        seq->push_back(p);
        vis[p] = true;
        p = order[a[p]];
      }
      ans.push_back(seq);
    }
  }
  printf("%d\n", (int)ans.size());
  for (const vector<int>* v : ans) {
    printf("%d ", (int)v->size());
    for (int index : *v) printf("%d ", index + 1);
    putchar('\n');
  }
  return 0;
}
