#include <bits/stdc++.h>
using namespace std;
int a[100010], t[100010], vis[100010], cnt = 0;
vector<int> ans[100010];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) t[i] = a[i];
  sort(t, t + n);
  for (int i = 0; i < n; i++) a[i] = lower_bound(t, t + n, a[i]) - t;
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    int x = i;
    while (!vis[x]) {
      vis[x] = 1;
      ans[cnt].push_back(x);
      x = a[x];
    }
    cnt++;
  }
  cout << cnt << '\n';
  for (int i = 0; i < cnt; i++) {
    sort(ans[i].begin(), ans[i].end());
    int sz = ans[i].size();
    cout << sz;
    for (int j = 0; j < sz; j++) cout << " " << ans[i][j] + 1;
    cout << '\n';
  }
  return 0;
}
