#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
int arr[N], old[N];
vector<int> adj[N];
bool vis[N];
int ans;
vector<vector<int>> vv;
vector<int> s;
void DFS(int i) {
  if (vis[i]) {
    return;
  }
  vis[i] = 1;
  s.push_back(i);
  for (int x = 0; x < adj[i].size(); ++x) DFS(adj[i][x]);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", arr + i);
    old[i] = arr[i];
  }
  sort(arr, arr + n);
  for (int i = 0; i < n; ++i) {
    if (old[i] != arr[i]) {
      int f = lower_bound(arr, arr + n, old[i]) - arr;
      adj[i].push_back(f);
      adj[f].push_back(i);
    } else
      adj[i].push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    DFS(i);
    if (s.size()) vv.push_back(s);
    s.clear();
  }
  printf("%d\n", vv.size());
  for (int i = 0; i < vv.size(); ++i) {
    printf("%d", vv[i].size());
    sort(vv[i].begin(), vv[i].end());
    for (vector<int>::iterator it = vv[i].begin(); it != vv[i].end(); ++it) {
      printf(" %d", (*it) + 1);
    }
    printf("\n");
  }
}
