#include <bits/stdc++.h>
using namespace std;
long long v[100100], vs[100100];
int dsu[100100];
int find(int n, long long key) {
  int lo = 0, hi = n - 1, mid;
  while (lo <= hi) {
    mid = (hi - lo) / 2 + lo;
    if (key < vs[mid]) {
      hi = mid - 1;
    } else if (key > vs[mid]) {
      lo = mid + 1;
    } else {
      return mid;
    }
  }
}
int root(int x) {
  if (dsu[x] == x) return x;
  dsu[x] = root(dsu[x]);
  return dsu[x];
}
void join(int a, int b) {
  dsu[a] = root(a);
  dsu[b] = root(b);
  dsu[dsu[a]] = dsu[b];
}
int main() {
  int n;
  cin >> n;
  for (int i = 0, _ = n; i < _; i++) {
    cin >> v[i];
    vs[i] = v[i];
  }
  sort(vs, vs + n);
  for (int i = 0, _ = n; i < _; i++) dsu[i] = i;
  int el, pos, components = 0;
  vector<vector<int> > groups(100100);
  for (int i = 0, _ = n; i < _; i++) {
    if (dsu[i] == i) {
      el = i;
      pos = find(n, v[el]);
      groups[components].push_back(el);
      while (root(el) != root(pos)) {
        join(pos, el);
        el = pos;
        groups[components].push_back(el);
        pos = find(n, v[el]);
      }
      components++;
    }
  }
  cout << components << endl;
  for (int i = 0, _ = components; i < _; i++) {
    cout << groups[i].size();
    for (int j = 0, _ = groups[i].size(); j < _; j++) {
      cout << " " << groups[i][j] + 1;
    }
    cout << endl;
  }
}
