#include <bits/stdc++.h>
using namespace std;
int a[55][55];
int main() {
  int n;
  cin >> n;
  vector<int> vec;
  map<int, int> idx;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    vec.push_back(x);
    idx[x] = i;
  }
  auto sortvec = vec;
  sort(sortvec.begin(), sortvec.end());
  map<int, int> ma, vis;
  for (int i = 0; i < n; i++) {
    ma[sortvec[i]] = vec[i];
  }
  vector<set<int>> se;
  for (int i = 0; i < n; i++) {
    int x = vec[i];
    if (vis[x]) continue;
    se.push_back(set<int>());
    while (!vis[x]) {
      vis[x] = true;
      se.back().insert(idx[x] + 1);
      x = ma[x];
    }
  }
  cout << se.size() << "\n";
  for (auto x : se) {
    cout << x.size() << " ";
    for (auto nx : x) {
      cout << nx << " ";
    }
    cout << "\n";
  }
  return 0;
}
