#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b.begin(), b.end());
  vector<int>::iterator it;
  bool flag[n];
  for (int i = 0; i < n; i++) flag[i] = true;
  vector<int> vec[n];
  int cnt = 0, idx;
  bool hint = false;
  for (int i = 0; i < n; i++) {
    int j = i;
    while (flag[j]) {
      hint = true;
      flag[j] = false;
      vec[cnt].push_back(j + 1);
      it = lower_bound(b.begin(), b.end(), a[j]);
      idx = (it - b.begin());
      j = idx;
    }
    if (hint) {
      cnt++;
    }
    hint = false;
  }
  cout << cnt << endl;
  for (int i = 0; i < cnt; i++) {
    cout << vec[i].size() << " ";
    for (int j = 0; j < vec[i].size(); j++) {
      cout << vec[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
