#include <bits/stdc++.h>
using namespace std;
bool shown[100001];
vector<pair<int, int> > v;
vector<int> cycle;
vector<vector<int> > ans;
int main() {
  int n, tmp;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &tmp);
    v.push_back(make_pair(tmp, i));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    int j = i;
    while (!shown[v[j].second]) {
      shown[v[j].second] = true;
      cycle.push_back(v[j].second);
      j = v[j].second;
    }
    if (cycle.size() != 0) {
      sort(cycle.begin(), cycle.end());
      ans.push_back(cycle);
      cycle.clear();
    }
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d", ans[i].size());
    for (int j = 0; j < ans[i].size(); j++) printf(" %d", ans[i][j] + 1);
    printf("\n");
  }
}
