#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
const int maxn = 100000 + 10;
const int mod = 1e9 + 7;
int n;
int p[123456];
int a[123456];
int b[123456];
int vis[123456];
vector<int> ans[123456];
int tot = 0;
void dfs(int x) {
  ans[tot].push_back(x);
  vis[x] = 1;
  int pos = lower_bound(b + 1, b + 1 + n, a[x]) - b;
  if (!vis[pos]) dfs(pos);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
      tot++;
    }
  }
  cout << tot << endl;
  for (int i = 0; i < tot; i++) {
    printf("%d", ans[i].size());
    for (int j = 0; j < ans[i].size(); j++) {
      printf(" %d", ans[i][j]);
    }
    puts("");
  }
  return 0;
}
