#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, j, k, x, y, z, t;
  cin >> n;
  vector<long long> u, v, w[n + 5];
  for (i = 0; i < n; i++) {
    cin >> x;
    u.push_back(x);
  }
  v = u;
  sort(v.begin(), v.end());
  map<long long, long long> mp;
  for (i = 0; i < n; i++) {
    mp[v[i]] = i;
  }
  long long ans = 0;
  for (i = 0; i < n; i++) {
    if (u[i] == INT_MAX) continue;
    if (u[i] == v[i]) {
      w[i].push_back(i + 1);
      ans++;
    } else {
      k = i;
      while (u[k] != v[i]) {
        w[i].push_back(k + 1);
        x = k;
        k = mp[u[x]];
        u[x] = INT_MAX;
      }
      w[i].push_back(k + 1);
      u[k] = INT_MAX;
      ans++;
    }
  }
  cout << ans << endl;
  for (i = 0; i < n; i++) {
    if (w[i].size() == 0) continue;
    cout << w[i].size() << " ";
    for (j = 0; j < w[i].size(); j++) cout << w[i][j] << " ";
    cout << endl;
  }
}
