#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int uf[N], a[N], b[N];
unordered_map<int, int> loc;
vector<int> locs[N];
int id(int v) {
  if (uf[v] == v) return v;
  return uf[v] = id(uf[v]);
}
void merge(int u, int v) {
  u = id(u), v = id(v);
  if (u == v) return;
  uf[u] = v;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) uf[i] = i;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    b[i] = a[i];
  }
  sort(b, b + n);
  for (int i = 0; i < n; ++i) loc[b[i]] = i;
  for (int i = 0; i < n; ++i) merge(i, loc[a[i]]);
  for (int i = 0; i < n; ++i) {
    locs[id(i)].push_back(i);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) ans += locs[i].size() != 0;
  printf("%d\n", ans);
  for (int i = 0; i < n; ++i) {
    if (locs[i].size()) {
      printf("%d", int(locs[i].size()));
      for (auto a : locs[i]) printf(" %d", a + 1);
      printf("\n");
    }
  }
}
