#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long x;
  vector<pair<long long, long long> > a(n);
  for (int i = 0; i < n; i++) {
    cin >> x;
    a[i].first = x;
    a[i].second = i;
  }
  sort(a.begin(), a.end());
  long long arr[3 * n], l = 0, len = 0;
  for (int i = 0; i < n; i++) {
    if (a[i].first < 2E9) {
      len++;
      arr[l++] = 1;
      int y = l - 1;
      arr[l++] = a[i].second + 1;
      a[i].first = 2E9;
      x = a[i].second;
      while (i != x) {
        arr[y]++;
        a[x].first = 2E9;
        x = a[x].second;
        arr[l++] = x + 1;
      }
      arr[l++] = 0;
    }
  }
  cout << len << endl;
  for (int i = 0; i < l; i++) {
    if (arr[i] == 0)
      cout << endl;
    else
      cout << arr[i] << " ";
  }
  return 0;
}
