#include <bits/stdc++.h>
using namespace std;
const int N = 110000;
int n, a[N], id[N], fa[N], ans;
vector<int> v, an[N];
int get(int x) { return lower_bound(v.begin(), v.end(), x) - v.begin(); }
int get_fa(int x) { return fa[x] == x ? x : fa[x] = get_fa(fa[x]); }
void mer(int x, int y) {
  int tx = get_fa(x);
  int ty = get_fa(y);
  if (tx != ty) fa[tx] = ty;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    v.push_back(a[i]);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) id[i] = get(a[i]);
  for (int i = 0; i < n; i++) fa[i] = i;
  for (int i = 0; i < n; i++) mer(i, id[i]);
  for (int i = 0; i < n; i++) {
    an[get_fa(i)].push_back(i + 1);
  }
  for (int i = 0; i < n; i++)
    if (an[i].size()) ans++;
  printf("%d\n", ans);
  for (int i = 0; i < n; i++) {
    if (an[i].size()) {
      printf("%d ", an[i].size());
      for (int j = 0; j < an[i].size(); j++) printf("%d ", an[i][j]);
      puts("");
    }
  }
}
