#include <bits/stdc++.h>
using namespace std;
template <typename G>
inline void read(G &x) {
  x = 0;
  char c;
  while (!isdigit(c = getchar()))
    ;
  do {
    x = x * 10 + c - '0';
  } while (isdigit(c = getchar()));
}
template <typename G>
inline void write(G x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
inline T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <class T>
inline T min(T a, T b, T c, T d) {
  return min(a, min(b, c, d));
}
template <class T>
inline T max(T a, T b, T c) {
  return max(a, max(b, c));
}
template <class T>
inline T max(T a, T b, T c, T d) {
  return max(a, max(b, c, d));
}
const int MAXN = 1e5 * 5;
const int base = 1e9 + 7;
const int N = 5000;
int n, cnt, res;
int a[MAXN], b[MAXN], ans[MAXN], cl[MAXN];
vector<int> c[MAXN], t[MAXN];
void visit(int u) {
  ans[++cnt] = u;
  cl[u] = 1;
  for (int i = 0; int v = c[u][i]; ++i)
    if (!cl[v]) visit(v);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = (1); i <= (n); ++i) cin >> a[i];
  for (int i = (1); i <= (n); ++i) b[i] = a[i];
  sort(b + 1, b + n + 1);
  for (int i = (1); i <= (n); ++i) {
    int j = lower_bound(b + 1, b + n + 1, a[i]) - b;
    c[i].push_back(j);
  }
  for (int i = (1); i <= (n); ++i) c[i].push_back(0);
  for (int i = (1); i <= (n); ++i)
    if (cl[i] == 0) {
      cnt = 0;
      visit(i);
      if (cnt) {
        ++res;
        for (int j = (1); j <= (cnt); ++j) t[res].push_back(ans[j]);
      }
    }
  cout << res << '\n';
  for (int i = (1); i <= (res); ++i) {
    cout << t[i].size() << ' ';
    for (int j = (0); j < (t[i].size()); ++j) cout << t[i][j] << ' ';
    cout << '\n';
  }
  return 0;
}
