#include <bits/stdc++.h>
using namespace std;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
int n, pos[N], a[N], vis[N], s, ans;
vector<pair<int, int> > v;
vector<int> ret[N];
void dfs(int u) {
  vis[u] = true;
  ret[ans].push_back(u);
  if (u == s) return;
  dfs(pos[u]);
}
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    v.push_back(make_pair(a[i], i));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) pos[v[i].second] = i;
  ans = 0;
  for (int i = 0; i < n; i++) vis[i] = 0;
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      s = i;
      dfs(pos[i]);
      ans++;
    }
  }
  cout << ans << endl;
  for (int i = 0; i < ans; i++) {
    cout << (int)ret[i].size() << " ";
    for (int j = 0; j < ret[i].size(); j++) {
      cout << ret[i][j] + 1 << " ";
    }
    cout << endl;
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
