#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 5;
int a[MAX_N], used[MAX_N];
pair<int, int> b[MAX_N];
vector<int> g[MAX_N], path;
vector<vector<int> > ans;
void dfs(int v) {
  used[v] = 1;
  path.push_back(v);
  for (int u : g[v])
    if (!used[u]) dfs(u);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; (i) < (n); ++i) scanf("%d", &a[i]), b[i] = make_pair(a[i], i);
  sort(b, b + n);
  for (int i = 0; (i) < (n); ++i) g[i].push_back(b[i].second);
  for (int i = 0; (i) < (n); ++i)
    if (!used[i]) {
      dfs(i);
      ans.push_back(path);
      path.clear();
    }
  printf("%d\n", (int)((ans).size()));
  for (auto &path : ans) {
    printf("%d ", (int)((path).size()));
    for (int v : path) printf("%d ", v + 1);
    puts("");
  }
  return 0;
}
