#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> v, u;
  map<long long, long long> m;
  map<long long, int> x;
  int j = 0;
  vector<set<long long> > ans(100000);
  set<long long>::iterator itr;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    x.insert(make_pair(a, i + 1));
    v.push_back(a);
    u.push_back(a);
  }
  sort(u.begin(), u.end());
  for (int i = 0; i < n; i++) m.insert(make_pair(v[i], u[i]));
  int k = 0;
  for (int i = 0; i < v.size(); i++) {
    if (x[v[i]] != -1) {
      long long a = v[i];
      long long b = u[i];
      ans[k].insert(x[a]);
      x[a] = -1;
      while (a != b) {
        ans[k].insert(x[b]);
        x[b] = -1;
        b = m[b];
      }
      k++;
    }
  }
  cout << k << "\n";
  for (int i = 0; i < k; i++) {
    cout << ans[i].size() << " ";
    for (itr = ans[i].begin(); itr != ans[i].end(); itr++) cout << *itr << " ";
    cout << "\n";
  }
  return 0;
}
