#include <bits/stdc++.h>
using namespace std;
bitset<100010> used;
pair<int, int> arr[100010];
pair<int, int> sArr[100010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i].first), arr[i].second = i;
  for (int i = 0; i < n; i++)
    sArr[i].first = arr[i].first, sArr[i].second = arr[i].second;
  sort(sArr, sArr + n);
  vector<vector<int> > subs;
  vector<int> currSub;
  for (int i = 0; i < n; i++) {
    currSub.clear();
    if (!used[i]) {
      currSub.push_back(sArr[i].second);
      used.set(sArr[i].second);
      int j = i;
      if (!used[arr[j].second])
        currSub.push_back(arr[j].second), used.set(arr[j].second);
      while (!used[sArr[sArr[j].second].second]) {
        currSub.push_back(sArr[sArr[j].second].second);
        used.set(sArr[sArr[j].second].second);
        j = sArr[j].second;
      }
    }
    if (currSub.size() > 0) subs.push_back(currSub);
  }
  printf("%d\n", subs.size());
  for (int i = 0; i < subs.size(); i++) {
    printf("%d ", subs[i].size());
    for (int j = 0; j < subs[i].size(); j++) printf("%d ", subs[i][j] + 1);
    printf("\n");
  }
  return 0;
}
