#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> a(N);
vector<int> b(N);
vector<vector<int>> adj(N);
vector<int> vis(N);
pair<int, int> p[N];
int idx[] = {0, -1, 0, 1};
int idy[] = {1, 0, -1, 0};
int n;
int main() {
  int n;
  cin >> n;
  int ans = 0;
  vector<vector<int>> temp;
  for (int i = 1; i <= n; i++) {
    cin >> p[i].first;
    p[i].second = i;
  }
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; i++) b[i] = p[i].second;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    int next = i;
    vector<int> xv;
    while (!vis[next]) {
      xv.push_back(next);
      vis[next] = 1;
      next = b[next];
    }
    temp.push_back(xv);
  }
  cout << temp.size() << endl;
  for (auto i : temp) {
    cout << i.size() << " ";
    for (auto j : i) cout << j << " ";
    cout << endl;
  }
  return 0;
}
