#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; ++i) {
    int ai;
    cin >> ai;
    a[i] = {ai, i};
  }
  sort(a.begin(), a.end());
  vector<int> pos(n);
  vector<vector<int>> ans;
  for (int i = 0; i < n; ++i) {
    pos[a[i].second] = i;
  }
  for (int i = 0; i < n; ++i) {
    vector<int> sub;
    if (pos[i] != -1) {
      sub.push_back(i);
      int cur = i, next = pos[i];
      pos[cur] = -1;
      while (next != i) {
        sub.push_back(next);
        cur = next;
        next = pos[next];
        pos[cur] = -1;
      }
      ans.push_back(sub);
    }
  }
  cout << ans.size() << '\n';
  for (auto ai : ans) {
    cout << ai.size() << ' ';
    for (auto si : ai) {
      cout << si + 1 << ' ';
    }
    cout << '\n';
  }
}
