#include <bits/stdc++.h>
using namespace std;
int a[100010];
int p[100010];
bool vis[100010];
int go[100010];
bool cmp(int x, int y) { return a[x] < a[y]; }
int cnt;
void show(int x, bool see) {
  if (vis[x] == true) return;
  vector<int> v;
  int cur = x;
  while (vis[cur] == false) {
    vis[cur] = true;
    v.push_back(cur);
    cur = go[cur];
  }
  if (see) {
    printf("%d", (int)v.size());
    for (auto i : v) {
      printf(" %d", i);
    }
    printf("\n");
  } else {
    ++cnt;
  }
}
int main(int argc, char const* argv[]) {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    p[i] = i;
  }
  sort(p + 1, p + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    go[p[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    show(i, false);
  }
  printf("%d\n", cnt);
  memset(vis, false, sizeof vis);
  for (int i = 1; i <= n; i++) {
    show(i, true);
  }
  return 0;
}
