#include <bits/stdc++.h>
using namespace std;
const int Inf = 1e9 + 7;
namespace myspace {
const int N = 1e5 + 7;
int n, a[N];
int p[N], b[N];
int vis[N];
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) p[i] = a[i];
  sort(p, p + n);
  for (int i = 0; i < n; i++) a[i] = lower_bound(p, p + n, a[i]) - p;
  for (int i = 0; i < n; i++) b[i] = i;
  vector<vector<int> > res;
  for (int i = 0; i < n; i++)
    if (vis[i] == 0) {
      int k = i;
      vector<int> cur;
      while (true) {
        if (vis[k] == 1) break;
        vis[k] = 1;
        cur.push_back(k);
        k = a[k];
      }
      res.push_back(cur);
    }
  cout << res.size() << '\n';
  for (auto e : res) {
    cout << e.size() << " ";
    for (auto ee : e) cout << (ee + 1) << " ";
    cout << '\n';
  }
}
};  // namespace myspace
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(9);
  cout << fixed;
  myspace::solve();
  return 0;
}
