#include <bits/stdc++.h>
using namespace std;
const int Z = (int)1e5 + 111;
const int inf = (int)1e9 + 111;
const long long llinf = (long long)1e18 + 5;
const int MOD = (int)1e9 + 7;
vector<int> ans[Z];
int a[Z];
pair<int, int> b[Z];
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    b[i].first = a[i];
    b[i].second = i;
  }
  int cnt = 0;
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; ++i) {
    if (a[i] == -inf) continue;
    set<int> cur_pos;
    cur_pos.insert(i);
    int pos = lower_bound(b + 1, b + 1 + n, make_pair(a[i], -inf)) - b;
    while (!cur_pos.count(pos)) {
      int x = pos;
      cur_pos.insert(pos);
      pos = lower_bound(b + 1, b + 1 + n, make_pair(a[pos], -inf)) - b;
      a[x] = -inf;
    }
    cnt++;
    for (int to : cur_pos) {
      ans[cnt].push_back(to);
    }
  }
  cout << cnt << '\n';
  for (int i = 1; i <= cnt; ++i) {
    cout << (int)ans[i].size() << ' ';
    for (int j = 0; j < (int)ans[i].size(); ++j) {
      cout << ans[i][j] << ' ';
    }
    cout << '\n';
  }
  return 0;
}
