#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int a[N * 10], b[N * 10];
bool used[N * 10];
map<int, int> f;
int main(int argc, const char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int(i) = 0; (i) < (n); ++(i)) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  for (int(i) = 0; (i) < (n); ++(i)) f[b[i]] = i;
  vector<vector<int> > ans;
  for (int(i) = 0; (i) < (n); ++(i)) {
    if (!used[i]) {
      int pos = i;
      vector<int> res;
      while (!used[pos]) {
        used[pos] = true;
        res.push_back(pos);
        pos = f[a[pos]];
      }
      ans.push_back(res);
    }
  }
  cout << ans.size() << endl;
  for (int(i) = 0; (i) < (ans.size()); ++(i)) {
    cout << ans[i].size();
    for (int(j) = 0; (j) < (ans[i].size()); ++(j)) {
      cout << " " << ans[i][j] + 1;
    }
    cout << endl;
  }
  return 0;
}
