#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, a[N], sa[N], r[N];
bool vis[N];
bool cmp(int x, int y) { return a[x] < a[y]; }
vector<int> v[N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sa[i] = i;
  sort(sa + 1, sa + n + 1, cmp);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      ans++;
      v[ans].push_back(i);
      vis[i] = 1;
      for (int x = sa[i]; x != i; x = sa[x]) vis[x] = 1, v[ans].push_back(x);
    }
  printf("%d\n", ans);
  for (int i = 1; i <= ans; i++) {
    printf("%d ", (int)v[i].size());
    for (int j = 0; j < v[i].size(); j++) printf("%d ", v[i][j]);
    puts("");
  }
  return 0;
}
