#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
int n;
int dig[N];
vector<int> ans[N];
bool vis[N];
int main() {
  cin >> n;
  vector<int> x;
  for (int i = (0); i < (n); i++) scanf("%d", &dig[i]), x.push_back(dig[i]);
  sort((x).begin(), (x).end());
  for (int i = (0); i < (n); i++)
    dig[i] = lower_bound((x).begin(), (x).end(), dig[i]) - x.begin();
  memset(vis, false, sizeof(vis));
  int ned = 0;
  for (int i = (0); i < (n); i++)
    if (!vis[i]) {
      for (int u = i; !vis[u]; u = dig[u]) vis[u] = true, ans[ned].push_back(u);
      ned++;
    }
  printf("%d\n", ned);
  for (int i = (0); i < (ned); i++) {
    printf("%d", ((int)(ans[i]).size()));
    for (int j = (0); j < (((int)(ans[i]).size())); j++)
      printf(" %d", ans[i][j] + 1);
    printf("\n");
  }
}
