#include <bits/stdc++.h>
using namespace std;
bool vis[100001];
int main() {
  map<int, vector<int> > final;
  map<int, int> mp;
  int n, x, y, val[100001];
  vector<pair<int, int> > ar;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> val[i], ar.push_back({val[i], i});
  sort(ar.begin(), ar.end());
  for (int i = 0; i < n; i++) mp[ar[i].first] = i;
  int cnt = 0;
  for (int i = 0; i < n; i++)
    if (vis[i] == 0) {
      int value = val[i];
      int idx = mp[value];
      vis[i] = 1;
      vector<int> res;
      res.push_back(i);
      while (!vis[idx]) {
        vis[idx] = 1, res.push_back(idx);
        value = val[idx];
        if (idx == mp[value]) break;
        idx = mp[value];
      }
      final[cnt++] = res;
    }
  cout << final.size() << '\n';
  for (auto it = final.begin(); it != final.end(); it++) {
    cout << it->second.size() << ' ';
    for (auto p : it->second) cout << p + 1 << ' ';
    cout << '\n';
  }
}
