#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i].first;
    arr[i].second = i;
  }
  sort(arr.begin(), arr.end());
  vector<vector<int>> result;
  vector<bool> used(n, false);
  int rem;
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      vector<int> row;
      rem = arr[i].second;
      row.push_back(i + 1);
      used[i] = true;
      while (rem != i) {
        used[rem] = true;
        row.push_back(rem + 1);
        rem = arr[rem].second;
      }
      result.push_back(row);
    }
  }
  cout << result.size() << endl;
  for (int i = 0; i < result.size(); i++) {
    cout << result[i].size() << ' ';
    for (int j = 0; j < result[i].size(); j++) cout << result[i][j] << ' ';
    cout << endl;
  }
  return 0;
}
