#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int MOD = 1000000007;
int vis[100005];
vector<vector<int>> res;
vector<vector<int>> adj;
void dfs(int source, int ind) {
  vis[source] = 1;
  res[ind].push_back(source);
  for (int val : adj[source])
    if (!vis[val]) dfs(val, ind);
}
signed main() {
  cin.tie(0), cout.tie(0);
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  int a[n];
  int b[n];
  for (int i = 0; i < n; i++) cin >> a[i], b[i] = a[i];
  sort(b, b + n);
  map<int, int> mp;
  for (int i = 0; i < n; i++) mp[b[i]] = i;
  adj.resize(n + 1);
  for (int i = 0; i < n; i++) adj[i].push_back(mp[a[i]]);
  int cur = 0;
  for (int i = 0; i < n; i++)
    if (!vis[i]) res.resize(cur + 1), dfs(i, cur++);
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); i++) {
    cout << res[i].size() << " ";
    for (int j = 0; j < res[i].size(); j++) cout << res[i][j] + 1 << " ";
    cout << endl;
  }
  return 0;
}
