#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> vec[111111];
int num1[N], num2[N], pos[N];
int main() {
  int n, i, j;
  cin >> n;
  for (i = 1; i <= n; i++) {
    scanf("%d", &num1[i]);
    num2[i] = num1[i];
  }
  sort(num2 + 1, num2 + n + 1);
  map<int, int> mp;
  for (i = 1; i <= n; i++) {
    mp[num2[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    pos[i] = mp[num1[i]];
  }
  int vis[N] = {0};
  int cnt = 0;
  for (i = 1; i <= n; i++) {
    if (!vis[i]) {
      int x = i;
      while (!vis[x]) {
        vis[x] = 1;
        vec[cnt].push_back(x);
        x = pos[x];
      }
      cnt++;
    }
  }
  cout << cnt << '\n';
  for (i = 0; i < cnt; i++) {
    int len = vec[i].size();
    if (len) cout << len;
    for (j = 0; j < len; j++) printf(" %d", vec[i][j]);
    if (len) puts("");
  }
}
