#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> nos(N), v(N);
  map<int, int> m;
  for (int i = 0; i < N; i++) cin >> nos[i];
  v = nos;
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) m[v[i]] = i;
  vector<vector<int> > segs;
  vector<bool> used(N, false);
  for (int i = 0; i < N; i++) {
    if (used[i] == true) continue;
    vector<int> curr;
    curr.push_back(i);
    used[i] = true;
    int idx = m[nos[i]];
    while (idx != i) {
      used[idx] = true;
      curr.push_back(idx);
      idx = m[nos[idx]];
    }
    segs.push_back(curr);
  }
  cout << segs.size() << endl;
  for (auto v : segs) {
    cout << v.size() << " ";
    for (auto x : v) cout << x + 1 << " ";
    cout << endl;
  }
  return 0;
}
