#include <bits/stdc++.h>
using namespace std;
constexpr int N = 100005;
int original[N], sorted[N];
bool done[N];
map<int, int> actually;
map<int, int> must_be_at;
set<int> answers[N];
int main(void) {
  int n;
  scanf("%d", &n);
  original[100002] = 1e9 + 7;
  for (int i = 0; i < n; i++) {
    scanf("%d", original + i);
    sorted[i] = original[i];
  }
  sort(sorted, sorted + n);
  for (int i = 0; i < n; i++) {
    actually.insert({original[i], i});
    must_be_at.insert({sorted[i], i});
  }
  int ansc = 0;
  for (int i = 0; i < n; i++) {
    if (done[i]) continue;
    auto &used = answers[ansc++];
    used.insert(i);
    int nxt = must_be_at[original[i]];
    int prv = i;
    while (used.find(nxt) == used.end()) {
      used.insert(nxt);
      prv = nxt;
      nxt = must_be_at[original[nxt]];
      done[prv] = true;
      done[nxt] = true;
    }
  }
  printf("%d\n", ansc);
  for (int i = 0; i < ansc; i++) {
    printf("%d ", (int)answers[i].size());
    for (int a : answers[i]) {
      printf("%d ", a + 1);
    }
    puts("");
  }
  return 0;
}
