#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
const int MX = 1e9 + 7;
const int inf = 1e9 + 9;
int n, m;
int cnt = 0;
pair<int, int> tab[N];
bool vis[N];
vector<int> res[N];
void dfs(int u) {
  vis[u] = true;
  res[cnt].push_back(u);
  if (!vis[tab[u].second]) dfs(tab[u].second);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &tab[i].first), tab[i].second = i;
  sort(tab + 1, tab + n + 1);
  for (int i = 1; i <= n; ++i) {
    if (vis[i]) continue;
    ++cnt;
    dfs(i);
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; ++i) {
    printf("%d ", res[i].size());
    for (int v : res[i]) printf("%d ", v);
    puts("");
  }
  return 0;
}
