#include <bits/stdc++.h>
template <class T>
inline void read(T &x) {
  int t;
  while (((t = getchar()) < '0' || t > '9') && t != '-')
    ;
  bool flag = false;
  if (t == '-') flag = true, t = getchar();
  x = t - '0';
  while ((t = getchar()) >= '0' && t <= '9') x = x * 10 + (t - '0');
  if (flag) x = -x;
}
using namespace std;
const int maxn = 100010;
struct Node {
  int v, num;
  Node() {}
  Node(int a, int b) : v(a), num(b) {}
  bool operator<(Node B) const { return v < B.v; }
} a[maxn];
int n;
int f[maxn];
vector<int> vec[maxn];
int getf(int x) { return f[x] < 0 ? x : (f[x] = getf(f[x])); }
bool merge(int x, int y) {
  x = getf(x), y = getf(y);
  if (x == y) return false;
  if (f[x] < f[y])
    f[x] += f[y], f[y] = x;
  else
    f[y] += f[x], f[x] = y;
  return true;
}
int main() {
  read(n);
  for (int i = 1; i <= n; ++i) {
    read(a[i].v);
    a[i].num = i;
  }
  sort(a + 1, a + n + 1);
  memset(f, -1, sizeof f);
  int cnt = n;
  for (int i = 1; i <= n; ++i)
    if (merge(i, a[i].num)) --cnt;
  printf("%d\n", cnt);
  for (int i = 1; i <= n; ++i) vec[getf(i)].push_back(i);
  for (int i = 1; i <= n; ++i) {
    if (i == getf(i)) {
      int sz = (int)vec[i].size();
      printf("%d ", sz);
      for (int j = 0; j < sz; ++j) printf("%d ", vec[i][j]);
      puts("");
    }
  }
  return 0;
}
