#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int cont[200005], st[200005], p[200005], u[200005];
int main() {
  int n;
  while (cin >> n) {
    memset(u, 0, sizeof(u));
    ;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
      cin >> cont[i];
      st[i] = cont[i];
    }
    sort(st, st + n);
    for (int i = 0; i < n; i++) {
      mp[st[i]] = i;
    }
    for (int i = 0; i < n; i++) {
      p[i] = mp[cont[i]];
    }
    vector<vector<int>> ans;
    for (int i = 0; i < n; i++) {
      if (!u[i]) {
        u[i] = 1;
        vector<int> now;
        now.push_back(i + 1);
        int pos = p[i];
        while (pos != i) {
          u[pos] = 1;
          now.push_back(pos + 1);
          pos = p[pos];
        }
        ans.push_back(now);
      }
    }
    cout << ans.size() << '\n';
    for (auto i : ans) {
      cout << i.size() << ' ';
      for (auto j : i) {
        cout << j << ' ';
      }
      cout << '\n';
    }
  }
}
