#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 1e5 + 10;
vector<long long> adj[N];
vector<bool> vis(N, 0);
void dfs(long long s, vector<long long> &v) {
  vis[s] = 1;
  v.push_back(1 + s);
  for (auto w : adj[s]) {
    if (!vis[w]) {
      dfs(w, v);
    }
  }
}
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t;
  t = 1;
  for (long long tc = 0; tc < t; tc++) {
    long long n;
    cin >> n;
    vector<long long> arr(n), brr(n);
    map<long long, long long> mp;
    for (long long i1 = 0; i1 < n; i1++) {
      cin >> arr[i1];
      mp[arr[i1]] = i1;
    }
    brr = arr;
    sort(brr.begin(), brr.end());
    for (long long i = 0; i < n; i++) {
      long long indx = mp[brr[i]];
      adj[i].push_back(indx);
      adj[indx].push_back(i);
    }
    vector<vector<long long> > ans;
    for (long long i = 0; i < n; i++) {
      if (!vis[i]) {
        vector<long long> v;
        dfs(i, v);
        ans.push_back(v);
      }
    }
    cout << ans.size() << "\n";
    for (auto v : ans) {
      cout << v.size() << " ";
      for (long long i = 0; i < (long long)v.size(); i++) cout << v[i] << " ";
      cout << "\n";
      ;
    }
  }
  return 0;
}
