#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  vector<long long> a(n);
  vector<bool> marked(n);
  fill((marked).begin(), (marked).end(), true);
  for (long long i = (0); i < (n); i++) cin >> a[i];
  vector<long long> c((a).begin(), (a).end());
  sort((c).begin(), (c).end());
  map<long long, long long> mp;
  for (long long i = (0); i < (n); i++) mp[c[i]] = i;
  vector<vector<long long>> ans;
  for (long long i = (0); i < (n); i++) {
    vector<long long> v;
    long long ind = mp[a[i]];
    if (marked[ind]) {
      marked[ind] = false;
      v.emplace_back(ind + 1);
      ind = mp[a[ind]];
      while (marked[ind]) {
        marked[ind] = false;
        v.emplace_back(ind + 1);
        ind = mp[a[ind]];
      }
      ans.emplace_back(v);
    }
  }
  cout << (long long)(ans.size()) << '\n';
  for (long long i = (0); i < ((long long)(ans.size())); i++) {
    cout << (long long)(ans[i].size()) << ' ';
    for (long long j = (0); j < ((long long)(ans[i].size())); j++)
      cout << ans[i][j] << ' ';
    cout << '\n';
  }
}
