#include <bits/stdc++.h>
using namespace std;
vector<int> g[100007];
bool used[100007];
vector<int> cur;
void dfs(int v) {
  used[v] = true;
  cur.push_back(v);
  for (int(i) = 0; (i) < ((int)(g[v]).size()); (i)++) {
    int to = g[v][i];
    if (!used[to]) {
      dfs(to);
    }
  }
}
int main() {
  vector<vector<int> > ans;
  pair<int, int> arr[100007];
  int n;
  scanf("%d", &n);
  memset((used), (false), sizeof((used)));
  for (int(i) = 0; (i) < (n); (i)++) {
    scanf("%d", &arr[i].first);
    arr[i].second = i;
  }
  sort(arr, arr + n);
  for (int(i) = 0; (i) < (n); (i)++) {
    g[i].push_back(arr[i].second);
    g[arr[i].second].push_back(i);
  }
  for (int(i) = 0; (i) < (n); (i)++) {
    if (!used[i]) {
      cur.clear();
      dfs(i);
      ans.push_back(cur);
    }
  }
  printf("%d\n", (int)(ans).size());
  for (int(i) = 0; (i) < ((int)(ans).size()); (i)++) {
    printf("%d ", (int)(ans[i]).size());
    for (int(j) = 0; (j) < ((int)(ans[i]).size()); (j)++) {
      printf("%d ", ans[i][j] + 1);
    }
    printf("\n");
  }
  return 0;
}
