#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<pair<int, int> > arr;
  vector<pair<int, int> > ts;
  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    arr.push_back({temp, 0});
    ts.push_back({temp, i});
  }
  sort(ts.begin(), ts.end());
  for (int i = 0; i < n; i++) arr[ts[i].second].second = i;
  vector<vector<int> > cycles;
  vector<bool> visited(n, false);
  for (int i = 0; i < arr.size(); i++) {
    if (visited[i]) continue;
    vector<int> curr;
    int next = arr[i].second;
    int ci = i;
    curr.push_back(i);
    while (next != i) {
      int temp = arr[next].second;
      visited[next] = true;
      curr.push_back(next);
      swap(arr[ci], arr[next]);
      ci = next;
      next = temp;
    }
    cycles.push_back(curr);
  }
  cout << cycles.size() << endl;
  for (int i = 0; i < cycles.size(); i++) {
    cout << cycles[i].size() << " ";
    for (int j = 0; j < cycles[i].size(); j++) cout << cycles[i][j] + 1 << " ";
    cout << endl;
  }
  return 0;
}
