#include <bits/stdc++.h>
using namespace std;
int vis[100005] = {0};
int a[100005], b[100005];
vector<pair<int, int> > bb;
vector<vector<int> > v(100005);
vector<vector<int> > vv(100005);
void dfs(int x, vector<int> &tv, int id) {
  vis[x] = 1;
  tv.push_back(x);
  for (int i = 0; i < v[x].size(); i++) {
    if (!vis[v[x][i]]) dfs(v[x][i], tv, id);
  }
}
int main() {
  int n, j;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
    bb.push_back(make_pair(a[i], i));
  }
  sort(bb.begin(), bb.end());
  for (int i = 0; i < n; i++) {
    j = bb[i].second;
    v[i].push_back(j);
    v[j].push_back(i);
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      vector<int> tv;
      dfs(i, tv, sum);
      sum++;
      for (int ll = 0; ll < tv.size(); ll++) {
        vv[sum - 1].push_back(tv[ll]);
      }
    }
  }
  cout << sum << endl;
  for (int i = 0; i < sum; i++) {
    cout << vv[i].size() << " ";
    for (int j = 0; j < vv[i].size(); j++) {
      cout << vv[i][j] + 1 << " ";
    }
    cout << endl;
  }
  return 0;
}
