#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
int n;
int a[N];
int go[N];
bool used[N];
vector<int> all;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    all.push_back(a[i]);
  }
  sort(all.begin(), all.end());
  all.resize(unique(all.begin(), all.end()) - all.begin());
  for (int i = 1; i <= n; i++) {
    int pos = upper_bound(all.begin(), all.end(), a[i]) - all.begin();
    go[i] = pos;
  }
  vector<vector<int>> ans;
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      vector<int> now;
      for (int j = i; !used[j]; j = go[j]) now.push_back(j), used[j] = true;
      ans.push_back(now);
    }
  }
  printf("%d\n", (int)ans.size());
  for (auto it : ans) {
    printf("%d ", (int)it.size());
    for (auto qq : it) printf("%d ", qq);
    puts("");
  }
  return 0;
}
