#include <bits/stdc++.h>
using namespace std;
int n;
int p[123456];
int a[123456];
int b[123456];
int vis[123456];
vector<int> ans[123456];
int total = 0;
void dfs(int x) {
  ans[total].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() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
      total++;
    }
  }
  cout << total << endl;
  for (int i = 0; i < total; i++) {
    cout << ans[i].size() << " ";
    for (int j = 0; j < ans[i].size(); j++) {
      cout << ans[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}
