#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  ll a[n];
  for (int i = 0; i < (n); ++i) cin >> a[i];
  map<int, int> mp;
  for (int i = 0; i < n; i++) mp[a[i]] = i;
  sort(a, a + n);
  int vis[n];
  memset(vis, 0, sizeof(vis));
  vector<vector<int> > v;
  for (int i = 0; i < n; i++) {
    if (vis[i] == 0) {
      vector<int> t;
      ll x = i;
      while (vis[x] == 0) {
        t.push_back(x);
        vis[x] = 1;
        x = mp[a[x]];
      }
      v.push_back(t);
    }
  }
  cout << v.size() << "\n";
  for (auto i : v) {
    cout << i.size() << " ";
    for (auto j : i) cout << j + 1 << " ";
    cout << "\n";
  }
  return 0;
}
