#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && (c != '-')) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
const int N = 1e5 + 10;
int n, p[N], vis[N], cnt;
pair<int, int> a[N];
vector<int> ans[N];
int main() {
  n = read();
  for (register int i = (1); i <= (n); i++) a[i] = make_pair(read(), i);
  sort(a + 1, a + 1 + n);
  for (register int i = (1); i <= (n); i++) p[a[i].second] = i;
  for (register int i = (1); i <= (n); i++)
    if (!vis[i]) {
      ++cnt;
      for (int j = i; !vis[j]; j = p[j]) vis[j] = 1, ans[cnt].push_back(j);
    }
  printf("%d\n", cnt);
  for (register int i = (1); i <= (cnt); i++) {
    printf("%d ", ((int)(ans[i]).size()));
    sort((ans[i]).begin(), (ans[i]).end());
    for (auto j : ans[i]) printf("%d ", j);
    puts("");
  }
}
