#include <bits/stdc++.h>
using namespace std;
int arr[100003];
int brr[100003];
bool visited[100003];
map<int, int> mp;
vector<int> vec;
vector<vector<int> > ans;
void dfs(int node) {
  visited[node] = 1;
  vec.push_back(node);
  int next = mp[arr[node]];
  if (!visited[next]) dfs(next);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    brr[i] = arr[i];
  }
  sort(brr, brr + n);
  for (int i = 0; i < n; i++) mp[brr[i]] = i;
  for (int i = 0; i < n; i++) {
    if (!visited[i]) {
      vec.clear();
      dfs(i);
      ans.push_back(vec);
    }
  }
  printf("%d\n", (int)ans.size());
  for (auto i : ans) {
    printf("%d ", (int)i.size());
    sort(i.begin(), i.end());
    for (int j = 0; j < i.size(); j++) {
      printf("%d", i[j] + 1);
      if (j != i.size() - 1) printf(" ");
    }
    printf("\n");
  }
}
