#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  int temp[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    temp[i] = arr[i];
  }
  int visit[n];
  for (int i = 0; i < n; i++) {
    visit[i] = 0;
  }
  sort(temp, temp + n);
  map<int, int> mymap;
  for (int i = 0; i < n; i++) {
    mymap[temp[i]] = i;
  }
  set<vector<int> > myset;
  for (int i = 0; i < n; i++) {
    if (visit[i] == 0) {
      vector<int> myvec;
      myvec.push_back(i);
      visit[i] = 1;
      int index = mymap[arr[i]];
      while (visit[index] == 0) {
        visit[index] = 1;
        myvec.push_back(index);
        index = mymap[arr[index]];
      }
      myset.insert(myvec);
    }
  }
  cout << myset.size() << endl;
  while (!myset.empty()) {
    vector<int> myvec = *myset.begin();
    vector<int>::iterator itr;
    myset.erase(myset.begin());
    cout << myvec.size() << " ";
    for (itr = myvec.begin(); itr != myvec.end(); itr++) {
      cout << *itr + 1 << " ";
    }
    cout << endl;
  }
  return 0;
}
