#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const int maxn = 1e5 + 5;
struct node {
  int val, i;
} a[maxn];
int b[maxn], fa[maxn], e[maxn], vis[maxn];
vector<int> v[maxn];
int cmp(node x, node y) { return x.val < y.val; }
int find(int x) {
  if (x != fa[x]) fa[x] = find(fa[x]);
  return fa[x];
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].val);
    a[i].i = i;
  }
  sort(a, a + n, cmp);
  for (int i = 0; i < n; i++) {
    b[a[i].i] = i;
    fa[i] = i;
  }
  for (int i = 0; i < n; i++) {
    int x = find(i);
    int y = find(b[i]);
    fa[y] = x;
  }
  int tot = 0;
  for (int i = 0; i < n; i++) {
    int x = find(i);
    v[x].push_back(i);
    if (!vis[x]) {
      e[tot++] = x;
      vis[x] = 1;
    }
  }
  printf("%d\n", tot);
  for (int i = 0; i < tot; i++) {
    printf("%d", v[e[i]].size());
    for (int j = 0; j < v[e[i]].size(); j++) printf(" %d", v[e[i]][j] + 1);
    puts("");
  }
}
