#include <bits/stdc++.h>
using namespace std;
namespace ioput {
template <typename T>
T read() {
  T x = 0, f = 1;
  char c = getchar_unlocked();
  while ((c < '0') || (c > '9')) {
    if (c == '-') f = -1;
    c = getchar_unlocked();
  }
  while ((c >= '0') && (c <= '9'))
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar_unlocked();
  return x * f;
}
template <typename T>
void write(T x, char c) {
  static char t[25];
  static int tlen;
  t[tlen = 1] = c;
  if (x < 0) putchar_unlocked('-'), x = -x;
  do t[++tlen] = (x % 10) ^ 48;
  while (x /= 10);
  while (tlen) putchar_unlocked(t[tlen--]);
}
}  // namespace ioput
using namespace ioput;
const int maxn = 100005;
int n, a[maxn], idx[maxn], fa[maxn], tot;
vector<int> ans[maxn];
int find_fa(int x) { return x == fa[x] ? x : fa[x] = find_fa(fa[x]); }
int main() {
  n = read<int>();
  for (int i = 1, iend = n; i <= iend; ++i) {
    idx[i] = a[i] = read<int>();
    fa[i] = i;
  }
  sort(idx + 1, idx + 1 + n);
  for (int i = 1, iend = n; i <= iend; ++i) {
    int j = lower_bound(idx + 1, idx + 1 + n, a[i]) - idx;
    fa[find_fa(j)] = find_fa(i);
  }
  for (int i = 1, iend = n; i <= iend; ++i) {
    ans[find_fa(i)].push_back(i);
    if (fa[i] == i) ++tot;
  }
  printf("%d\n", tot);
  for (int i = 1, iend = n; i <= iend; ++i)
    if (fa[i] == i) {
      printf("%d ", ans[i].size());
      for (int j = 0, jend = ans[i].size() - 1; j <= jend; ++j)
        printf("%d%c", ans[i][j], j == jend ? '\n' : ' ');
    }
  return 0;
}
