#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b, long long int m) {
  long long int pp = (b == 0) ? 1 : power(a, b >> 1, m);
  pp = (pp * pp) % m;
  if (b & 1) pp = (pp * a) % m;
  return pp;
}
pair<long long int, long long int> a[100005];
bool vis[100005] = {0};
vector<long long int> b[100005];
signed main() {
  long long int n;
  scanf("%lld", &(n));
  for (long long int i = 1; i <= n; i++) {
    scanf("%lld", &(a[i].first));
    a[i].second = i;
  }
  sort(a + 1, a + n + 1);
  long long int c = 1;
  for (long long int i = 1; i <= n; i++) {
    long long int j = i;
    if (vis[a[i].second])
      continue;
    else {
      while (!vis[j]) {
        b[c].emplace_back(a[j].second);
        vis[j] = 1;
        j = a[j].second;
      }
      c++;
    }
  }
  printf("%lld ", (c - 1));
  printf("\n");
  for (long long int i = 1; i < c; i++) {
    cout << b[i].size() << " ";
    for (long long int j = 0; j < b[i].size(); j++) printf("%lld ", (b[i][j]));
    printf("\n");
  }
  return 0;
}
