#include <bits/stdc++.h>
const int N = 100010;
struct node {
  int idx, num;
  node() {}
  node(int idx, int num) : idx(idx), num(num) {}
  bool operator<(const node& rhs) const { return num < rhs.num; }
} p[N];
int n, go[N];
bool vis[N];
std::vector<int> v[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i].num);
    p[i].idx = i;
  }
  std::sort(p, p + n);
  for (int i = 0; i < n; i++) {
    go[p[i].idx] = i;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    for (int j = i; !vis[j]; j = go[j]) {
      vis[j] = true;
      v[ans].push_back(j);
    }
    ans++;
  }
  printf("%d\n", ans);
  for (int i = 0; i < ans; i++) {
    int sz = v[i].size();
    printf("%d ", sz);
    for (int j = 0; j < sz; j++) {
      printf("%d ", v[i][j] + 1);
    }
    printf("\n");
  }
  return 0;
}
