#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n;
  cin >> n;
  vector<int64_t> a;
  for (int64_t i = 0; i < n; i++) {
    int64_t a_i;
    cin >> a_i;
    a.push_back(a_i);
  }
  vector<int64_t> index;
  for (int64_t i = 0; i < n; i++) {
    index.push_back(i);
  }
  sort(index.begin(), index.end(),
       [&](int64_t x, int64_t y) { return a[x] < a[y]; });
  vector<int64_t> reverse(n);
  for (int64_t i = 0; i < n; i++) {
    reverse[index[i]] = i;
  }
  vector<vector<int64_t>> result;
  vector<bool> used(n, false);
  for (int64_t i = 0; i < n; i++) {
    if (used[i]) continue;
    vector<int64_t> v;
    int64_t t = i;
    do {
      v.push_back(t);
      used[t] = true;
      t = reverse[t];
    } while (!used[t]);
    result.push_back(v);
  }
  cout << result.size() << endl;
  for (auto& v : result) {
    cout << v.size();
    for (auto i : v) {
      cout << " " << i + 1;
    }
    cout << endl;
  }
}
