#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  static int a[100100];
  static int b[100100];
  static int ib[100100];
  static bool seen[100100];
  static vector<int> sub[100100];
  cin >> N;
  int i;
  for (((i)) = (0); ((i)) < ((N)); ((i))++) {
    cin >> a[i];
    b[i] = i;
  }
  sort(b, b + N, [](int i, int j) { return a[i] < a[j]; });
  for (((i)) = (0); ((i)) < ((N)); ((i))++) {
    ((void)0);
    ib[b[i]] = i + 1;
  }
  int ans = 0;
  for (((i)) = (0); ((i)) < ((N)); ((i))++) {
    if (seen[i]) continue;
    vector<int> &s = sub[ans++];
    ((void)0);
    do {
      s.push_back(i);
      ((void)0);
      seen[i] = true;
      i = b[i];
    } while (!seen[i]);
  }
  printf("%i\n", ans);
  for (((i)) = (0); ((i)) < ((ans)); ((i))++) {
    printf("%i", (int)sub[i].size());
    for (int x : sub[i]) printf(" %i", ib[x]);
    printf("\n");
  }
  return 0;
}
