#include <bits/stdc++.h>
using namespace std;
map<int, int> s;
int a[100500];
int wh[100500];
vector<vector<int> > now;
int clr[100500];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    s[a] = i;
  }
  int z = 0;
  for (auto p : s) {
    a[p.second] = z++;
  }
  for (int i = 0; i < n; i++) {
    if (clr[i]) {
      continue;
    }
    now.push_back(vector<int>());
    int u = i;
    while (!clr[u]) {
      now.back().push_back(u);
      clr[u] = 1;
      u = a[u];
    }
  }
  cout << now.size() << endl;
  for (auto &v : now) {
    cout << v.size() << ' ';
    for (auto x : v) {
      cout << x + 1 << ' ';
    }
    cout << endl;
  }
  return 0;
}
