#include <bits/stdc++.h>
using namespace std;
int n, ar[100001], arr[100001], sz;
std::vector<int> ans[100001];
void solve() {
  pair<int, int> arrPos[100001];
  for (int i = 0; i < n; i++) {
    arrPos[i].first = ar[i];
    arrPos[i].second = i;
  }
  sort(arrPos, arrPos + n);
  vector<bool> vis(n, false);
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    if (arrPos[i].second == i) {
      ans[sz++].push_back(i);
      continue;
    }
    int j = i;
    while (!vis[j]) {
      vis[j] = 1;
      j = arrPos[j].second;
      ans[sz].push_back(j);
    }
    sz++;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    ar[i] = arr[i];
  }
  sort(ar, ar + n);
  std::map<int, int> mp;
  for (int i = 0; i < n; i++) mp[ar[i]] = i + 1;
  for (int i = 0; i < n; i++) ar[i] = mp[arr[i]];
  solve();
  printf("%d\n", sz);
  for (int i = 0; i < sz; i++) {
    printf("%d ", ans[i].size());
    for (int j = 0; j < ans[i].size(); j++) printf("%d ", ans[i][j] + 1);
    printf("\n");
  }
  return 0;
}
