#include <bits/stdc++.h>
using namespace std;
int n, ans;
int a[100010], h[100010];
bool vis[100010];
vector<int> v[100010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
    h[i] = a[i];
  }
  sort(h + 1, h + n + 1);
  for (int i = 1; i <= n; ++i) {
    a[i] = lower_bound(h + 1, h + n + 1, a[i]) - h;
  }
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      ++ans;
      int x = i;
      while (!vis[x]) {
        vis[x] = true;
        v[ans].push_back(x);
        x = a[x];
      }
    }
  printf("%d\n", ans);
  for (int i = 1; i <= ans; ++i) {
    printf("%d", v[i].size());
    for (auto &y : v[i]) printf(" %d", y);
    printf("\n");
  }
}
