#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-9;
int a[100100], b[100100];
bool vis[100100];
vector<int> ans[100100];
int main() {
  int n;
  memset(vis, false, sizeof(vis));
  scanf("%d", &n);
  map<int, int> mp;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    mp[a[i]] = i;
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  int idx = 0;
  for (int i = 1; i <= n; ++i) {
    if (vis[i] == true) continue;
    if (a[i] == b[i]) {
      vis[i] = true;
      ans[idx].push_back(i);
      idx++;
      continue;
    }
    ans[idx].push_back(i);
    vis[i] = true;
    int pos = mp[b[i]];
    ans[idx].push_back(pos);
    vis[pos] = true;
    swap(a[i], a[pos]);
    if (a[pos] == b[pos]) {
      idx++;
      continue;
    }
    while (1) {
      int tmp = mp[b[pos]];
      vis[tmp] = true;
      ans[idx].push_back(tmp);
      swap(a[tmp], a[pos]);
      if (a[tmp] == b[tmp]) {
        idx++;
        break;
      }
      pos = tmp;
    }
  }
  printf("%d\n", idx);
  for (int i = 0; i < idx; ++i) {
    printf("%d", (int)ans[i].size());
    for (int j = 0; j < ans[i].size(); ++j) {
      printf(" %d", ans[i][j]);
    }
    putchar('\n');
  }
}
