#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn], b[maxn];
map<int, int> mp;
bool vis[maxn];
set<int> st[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    a[i] = x;
    b[i] = x;
  }
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; i++) mp[b[i]] = i;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i] == true) continue;
    cnt++;
    vis[i] = true;
    st[i].insert(i);
    int j = i;
    while (!st[i].count(mp[a[j]])) {
      vis[mp[a[j]]] = true;
      st[i].insert(mp[a[j]]);
      j = mp[a[j]];
    }
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++) {
    if (st[i].size() != 0) {
      printf("%d ", st[i].size());
      for (auto it = st[i].begin(); it != st[i].end(); it++) printf("%d ", *it);
      puts("");
    }
  }
  return 0;
}
