#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 4;
vector<long int> adjacency[MAXN];
bool visited[MAXN];
void dfs(long int pnt, set<long int> &indx) {
  if (visited[pnt]) return;
  visited[pnt] = 1;
  indx.insert(pnt);
  for (int pnter : adjacency[pnt]) dfs(pnter, indx);
}
int main() {
  long int pl;
  cin >> pl;
  long int myarr[pl];
  vector<pair<long int, long int>> vc2;
  for (long int i = 0; i < pl; i++) {
    cin >> myarr[i];
    vc2.push_back({myarr[i], i});
  }
  sort(vc2.begin(), vc2.end());
  for (long int i = 0; i < pl; i++) {
    adjacency[i + 1].push_back(vc2[i].second + 1);
    adjacency[vc2[i].second + 1].push_back(i + 1);
  }
  vector<set<long int>> vc;
  for (long int i = 1; i <= pl; i++) {
    if (visited[i] == 0) {
      set<long int> indx;
      dfs(i, indx);
      vc.push_back(indx);
    }
  }
  cout << vc.size() << endl;
  for (auto it : vc) {
    cout << it.size() << ' ';
    for (auto j : it) cout << j << ' ';
    cout << endl;
  }
  return 0;
}
