#include <bits/stdc++.h>
using namespace std;
int ax[100005];
pair<int, int> bx[100005];
int n, res;
int cx[100005];
list<int> dx[100005];
void dfs(int x) {
  cx[x] = res;
  dx[res].push_back(x);
  if (cx[ax[x]]) return;
  dfs(ax[x]);
}
void play() {
  for (int i = 1; i <= n; i++) {
    if (!cx[i]) {
      res++;
      dfs(i);
    }
  }
}
int main() {
  scanf("%d", &n);
  int i, j, a, b;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a);
    bx[i] = make_pair(a, i);
  }
  sort(bx + 1, bx + 1 + n);
  for (i = 1; i <= n; i++) ax[bx[i].second] = i;
  play();
  printf("%d\n", res);
  for (i = 1; i <= res; i++) {
    printf("%d ", dx[i].size());
    for (list<int>::iterator p = dx[i].begin(); p != dx[i].end(); p++)
      printf("%d ", *p);
    printf("\n");
  }
  return 0;
}
