#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[i] = {x, i};
  }
  sort(begin(a), end(a));
  vector<bool> seen(n);
  vector<vector<int>> cycles;
  for (int i = 0; i < n; i++) {
    if (seen[i]) continue;
    vector<int> cycle;
    int j = i;
    do {
      seen[j] = true;
      cycle.push_back(j);
      j = a[j].second;
    } while (j != i);
    cycles.push_back(cycle);
  }
  cout << cycles.size() << endl;
  for (const vector<int>& cycle : cycles) {
    cout << cycle.size() << " ";
    for (const int x : cycle) cout << x + 1 << " ";
    cout << "\n";
  }
}
