#include <bits/stdc++.h>
using namespace std;
pair<int, int> arr[100000];
bool vis[100000];
vector<vector<int>> cycles;
void process(int n, vector<int> &cycle) {
  if (vis[n]) return;
  vis[n] = true;
  cycle.push_back(n);
  process(arr[n].second, cycle);
}
int main() {
  int N;
  scanf("%d", &N);
  for (int n = 0; n < N; n++) {
    scanf("%d", &arr[n].first);
    arr[n].second = n;
  }
  sort(arr, arr + N);
  for (int n = 0; n < N; n++) {
    if (vis[n]) continue;
    vector<int> cycle;
    process(n, cycle);
    cycles.push_back(cycle);
  }
  int SZ = (int)cycles.size();
  printf("%d\n", SZ);
  for (int i = 0; i < SZ; i++) {
    int sz = (int)cycles[i].size();
    printf("%d ", sz);
    for (int j = 0; j < sz; j++) printf("%d ", cycles[i][j] + 1);
    printf("\n");
  }
  return 0;
}
