#include <bits/stdc++.h>
const int N = 1e5;
using namespace std;
bool used[N];
vector<int> a(N);
vector<vector<int> > k;
vector<int> g;
void dfs(int u) {
  g.push_back(u);
  used[u] = 1;
  if (!used[a[u]]) dfs(a[u]);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b;
  b = a;
  b.resize(n);
  sort(b.begin(), b.end());
  map<int, int> slov;
  for (int i = 0; i < n; i++) {
    slov[b[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    a[i] = slov[a[i]];
  }
  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      g.resize(0);
      dfs(i);
      k.push_back(g);
    }
  }
  cout << k.size() << endl;
  for (auto i : k) {
    cout << i.size() << " ";
    for (auto j : i) cout << j + 1 << " ";
    cout << endl;
  }
  return 0;
}
