#include <bits/stdc++.h>
using namespace std;
vector<long long int> a;
bool comp(long long int i1, long long int i2) { return a[i1] < a[i2]; }
int main() {
  long long int n;
  cin >> n;
  vector<long long int> ind1(n), ind2;
  a.resize(n);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
  for (int i = 0; i < n; i++) ind1[i] = i;
  ind2 = ind1;
  sort(ind2.begin(), ind2.end(), comp);
  int curr = 0;
  map<long long int, bool> vis;
  vector<set<long long int>> ans;
  while (vis.size() < n) {
    while (vis.find(curr) != vis.end()) curr++;
    set<long long int> tmp;
    int ptr = curr;
    while (tmp.find(ptr) == tmp.end()) {
      if (vis.find(ptr) != vis.end()) {
        cout << "Gadbad" << endl;
        exit(0);
      }
      tmp.insert(ptr);
      vis[ptr] = true;
      ptr = ind2[ptr];
    }
    ans.push_back(tmp);
  }
  cout << ans.size() << endl;
  for (auto it_vec : ans) {
    cout << it_vec.size() << " ";
    for (auto it_set : it_vec) {
      cout << it_set + 1 << " ";
    }
    cout << endl;
  }
}
