#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k = 0, p, l, c;
  scanf("%d", &n);
  int arr[n + 1], a[n + 1], ar[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
    a[i] = arr[i];
    ar[i] = 0;
  }
  sort(a + 1, a + n + 1);
  map<int, int> m;
  deque<int> dq, dq_ind;
  for (int i = 1; i <= n; i++) {
    m[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    p = i;
    c = 0;
    while (ar[p] == 0) {
      ar[p] = 1;
      c++;
      dq.push_back(p);
      p = m[arr[p]];
    }
    if (c > 0) {
      dq_ind.push_front(c);
      k++;
      for (int i = 0; i < c; i++) {
        dq_ind.push_front(dq[i]);
      }
      dq.clear();
    }
  }
  cout << k << endl;
  l = 0;
  while (!dq_ind.empty()) {
    p = dq_ind.back();
    cout << p << " ";
    dq_ind.pop_back();
    while (p--) {
      cout << dq_ind.back() << " ";
      dq_ind.pop_back();
    }
    cout << endl;
  }
}
