#include <bits/stdc++.h>
using namespace std;
int N;
int A[100005];
int SA[100005];
bool Vis[100005];
vector<int> Ans[100005];
bool CMP(int i, int j) { return (A[i] < A[j]); }
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    SA[i] = i;
  }
  sort(SA, SA + N, CMP);
  int idx = 0, Now;
  for (int i = 0; i < N; i++) {
    Now = i;
    if (!Vis[Now]) idx++;
    while (!Vis[Now]) {
      Vis[Now] = true;
      Now = SA[Now];
      Ans[idx].push_back(Now);
    }
  }
  printf("%d\n", idx);
  for (int i = 1; i <= idx; i++) {
    printf("%d ", Ans[i].size());
    for (int j = 0; j < Ans[i].size(); j++) printf("%d ", Ans[i][j] + 1);
    printf("\n");
  }
}
