#include <bits/stdc++.h>
using namespace std;
int n, m;
bool f[100009];
pair<int, int> a[100009];
vector<int> v[100009];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++)
    if (!f[i]) {
      int x = i;
      while (!f[x]) {
        f[x] = 1;
        v[m].push_back(x);
        x = a[x].second;
      }
      m++;
    }
  printf("%d\n", m);
  for (int i = 0; i < m; i++) {
    printf("%d ", v[i].size());
    for (int j = 0; j < v[i].size(); j++) printf("%d ", v[i][j]);
    printf("\n");
  }
  return 0;
}
