#include <bits/stdc++.h>
using namespace std;
vector<int> vis(100005, 0);
vector<int> num(100005);
int ans = 0;
vector<vector<int>> store(100005);
void dfs(int v) {
  if (vis[v]) return;
  store[ans].push_back(v);
  vis[v] = 1;
  dfs(num[v]);
}
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> vec(n);
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    vec[i] = {a, i};
  }
  sort((vec).begin(), (vec).end());
  for (int i = 0; i < n; i++) {
    num[i] = vec[i].second;
  }
  for (int i = 0; i < n; i++) {
    if (vis[i] == 0) {
      dfs(i);
      ans++;
    }
  }
  cout << ans << "\n";
  for (int i = 0; store[i].empty() == false; i++) {
    cout << store[i].size() << " ";
    for (int j = 0; j < store[i].size(); j++) {
      cout << store[i][j] + 1 << " ";
    }
    cout << "\n";
  }
}
