#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[100005];
vector<int> ans[100005];
int vis[100005];
int n;
int main() {
  cin >> n;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    a[i].first = x;
    a[i].second = i;
  }
  sort(a, a + n);
  int len = 0, m = 0;
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    m = i;
    while (!vis[m]) {
      ans[len].push_back(m + 1);
      vis[m] = 1;
      m = a[m].second;
    }
    len++;
  }
  cout << len << endl;
  for (int i = 0; i < len; i++) {
    cout << ans[i].size() << " ";
    for (int j = 0; j < ans[i].size(); j++) cout << ans[i][j] << " ";
    cout << endl;
  }
  return 0;
}
