#include <bits/stdc++.h>
using namespace std;
vector<long long int> graph[100001];
long long int vis[100001];
vector<long long int> sh;
void dfs(long long int x) {
  sh.push_back(x + 1);
  vis[x] = 1;
  long long int u;
  for (long long int i = 0; i < graph[x].size(); i++) {
    u = graph[x][i];
    if (!vis[u]) dfs(u);
  }
  return;
}
signed main() {
  long long int n, x, a[100001];
  cin >> n;
  vector<pair<long long int, long long int> > v;
  for (long long int i = 0; i < n; i++) cin >> x, v.push_back(make_pair(x, i));
  sort(v.begin(), v.end());
  for (long long int i = 0; i < n; i++)
    graph[i].push_back(v[i].second), graph[v[i].second].push_back(i);
  vector<vector<long long int> > ans;
  for (long long int i = 0; i < n; i++)
    if (!vis[i]) dfs(i), ans.push_back(sh), sh.clear();
  cout << ans.size() << endl;
  for (long long int i = 0; i < ans.size(); i++) {
    cout << ans[i].size() << " ";
    for (long long int j = 0; j < ans[i].size(); j++) cout << ans[i][j] << " ";
    cout << endl;
  }
  return 0;
}
