#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> in(n);
  vector<set<int>> ans;
  vector<bool> check(n);
  for (int i = 0; i < n; i++) scanf("%d", &in[i]);
  vector<int> in2(in.begin(), in.end());
  sort(in2.begin(), in2.end());
  for (int i = 0; i < n; i++) {
    int tmp = i;
    if (check[tmp] == false) {
      ans.push_back(set<int>());
      ans[ans.size() - 1].insert(tmp);
      check[tmp] = true;
      while (true) {
        int f = 0, t = n;
        while (t - f > 1) {
          int m = (f + t) / 2;
          if (in2[m] > in[tmp])
            t = m;
          else
            f = m;
        }
        tmp = (f + t) / 2;
        if (check[tmp] == true) break;
        ans[ans.size() - 1].insert(tmp);
        check[tmp] = true;
      }
    }
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d ", ans[i].size());
    for (auto &&j : ans[i]) printf("%d ", j + 1);
    printf("\n");
  }
  return 0;
}
