#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  int q[100009];
  vector<int> gh[100009];
  unordered_map<int, int> ind;
  vector<int> s;
  s.push_back(INT_MIN);
  int n, i, j, num, cnt = 1;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> num;
    q[i] = num;
    s.push_back(num);
  }
  i = 1;
  sort(s.begin(), s.end());
  for (int j = 1; j < s.size(); j++) ind[s[j]] = i++;
  int now, ni, oldnow, oldni;
  for (i = 1; i <= n; i++) {
    if (ind[q[i]] == -1) continue;
    now = q[i];
    ni = i;
    while (true) {
      oldnow = now;
      oldni = ni;
      now = q[ind[now]];
      ni = ind[oldnow];
      ind[oldnow] = -1;
      if (ni == -1) break;
      gh[cnt].push_back(oldni);
    }
    cnt++;
  }
  cout << cnt - 1 << endl;
  for (i = 1; i < cnt; i++) {
    cout << gh[i].size() << ' ';
    for (auto m : gh[i]) cout << m << ' ';
    cout << endl;
  }
  return 0;
}
