#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, a[maxn], ans;
pair<int, int> q[maxn];
int tar[maxn];
bool vis[maxn];
vector<int> subs[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    q[i] = make_pair(a[i], i);
  }
  sort(q + 1, q + n + 1);
  for (int i = 1; i <= n; i++) tar[q[i].second] = i, vis[i] = false;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      ans++;
      subs[ans].clear();
      int pos = i;
      while (!vis[pos]) {
        vis[pos] = true;
        subs[ans].push_back(pos);
        pos = tar[pos];
      }
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= ans; i++) {
    sort(subs[i].begin(), subs[i].end());
    printf("%d ", subs[i].size());
    for (int j = 0; j < subs[i].size(); j++) printf("%d ", subs[i][j]);
    printf("\n");
  }
  return 0;
}
