#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);
  using vec_t = pair<long long int, long long int>;
  vector<vec_t> vec;
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    vec.emplace_back(x, i);
  }
  sort(vec.begin(), vec.end());
  vector<bool> seen(n);
  vector<vector<long long int>> ans;
  for (long long int i = 0; i < n; i++) {
    if (seen[i]) continue;
    long long int j = i;
    vector<long long int> vv;
    while (!seen[j]) {
      seen[j] = true;
      vv.push_back(j);
      auto [x, p] = vec[j];
      j = p;
    };
    ans.push_back(move(vv));
  }
  cout << ans.size() << endl;
  for (const auto& v : ans) {
    cout << v.size();
    for (long long int p : v) {
      cout << " " << p + 1;
    }
    cout << "\n";
  }
  return 0;
}
