#include <bits/stdc++.h>
using namespace std;
int arr[100005];
map<int, int> indeksArr;
map<int, int> indeksSortedArr;
int main() {
  int n;
  while (scanf("%d", &n) == 1) {
    indeksArr.clear();
    indeksSortedArr.clear();
    for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
    int sortedArr[100005];
    for (int i = 0; i < n; i++) sortedArr[i] = arr[i];
    for (int i = 0; i < n; i++) {
      indeksArr[arr[i]] = i;
    }
    sort(sortedArr, sortedArr + n);
    for (int i = 0; i < n; i++) {
      indeksSortedArr[sortedArr[i]] = i;
    }
    bool sudah[100005] = {};
    vector<vector<int> > ans;
    for (int i = 0; i < n; i++) {
      if (sudah[i] == false) {
        sudah[i] = true;
        vector<int> temp;
        int indeks = indeksSortedArr[arr[i]];
        temp.push_back(indeks + 1);
        while (indeks != i) {
          int apa = arr[indeks];
          sudah[indeks] = true;
          temp.push_back(indeksSortedArr[apa] + 1);
          indeks = indeksSortedArr[apa];
        }
        ans.push_back(temp);
      }
    }
    cout << (int)ans.size() << endl;
    for (int i = 0; i < (int)ans.size(); i++) {
      cout << (int)ans[i].size();
      for (int j = 0; j < (int)ans[i].size(); j++) {
        cout << " " << ans[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}
