#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(false);
  long long n;
  cin >> n;
  vector<pair<long long, long long> > v(n);
  for (int i = 0; i < int(n); ++i) {
    cin >> v[i].first;
    v[i].second = i;
  }
  sort(v.begin(), v.end());
  vector<long long> p(n);
  for (int i = 0; i < int(n); ++i) p[v[i].second] = i;
  vector<vector<long long> > subs;
  vector<bool> seen(n);
  for (int i = 0; i < int(n); ++i) {
    if (seen[i]) continue;
    seen[i] = true;
    subs.push_back(vector<long long>(1, i));
    long long index = p[i];
    while (index != i) {
      seen[index] = true;
      subs[subs.size() - 1].push_back(index);
      index = p[index];
    }
  }
  cout << subs.size() << endl;
  for (int i = 0; i < int(subs.size()); ++i) {
    cout << subs[i].size();
    for (int j = 0; j < int(subs[i].size()); ++j) cout << " " << subs[i][j] + 1;
    cout << endl;
  }
}
