#include <bits/stdc++.h>
using namespace std;
pair<int, int> v[100000 + 1];
vector<int> sol[100000 + 1];
int is[100000 + 1];
int pos[100000 + 1];
int main() {
  int i, j, first, N, res = 0;
  scanf("%d", &N);
  for (i = 1; i <= N; ++i) {
    scanf("%d", &first);
    v[i] = {first, i};
  }
  sort(v + 1, v + N + 1);
  for (i = 1; i <= N; ++i)
    if (!is[i]) {
      ++res;
      is[i] = 1;
      for (j = v[i].second; j != i; j = v[j].second)
        is[j] = 1, sol[res].push_back(j);
      sol[res].push_back(i);
    }
  printf("%d\n", res);
  for (i = 1; i <= res; ++i) {
    printf("%d ", sol[i].size());
    for (j = 0; j < sol[i].size(); ++j) printf("%d ", sol[i][j]);
    printf("\n");
  }
  return 0;
}
