#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const long long LINF = INF * (long long)INF;
const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 100 * 1000 + 47;
int A[MAX], B[MAX];
int C[MAX];
map<int, int> I;
map<int, int> II;
int P[MAX];
int f(int x) {
  if (P[x] == x) return x;
  return P[x] = f(P[x]);
}
vector<int> ANS[MAX];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) scanf("%d", A + i), B[i] = A[i];
  sort(B, B + n);
  for (int i = (0); i < (n); i++) P[i] = i;
  for (int i = (0); i < (n); i++) {
  }
  for (int i = (0); i < (n); i++) {
    II[B[i]] = i;
  }
  int c = 0;
  for (int i = (0); i < (n); i++) {
    int ind = II[A[i]];
    int x = f(ind);
    ;
    int a = f(i);
    P[a] = x;
  }
  for (int i = (0); i < (n); i++) C[i] = f(i);
  for (int i = (0); i < (n); i++) ANS[C[i]].push_back(i + 1);
  for (int i = (0); i < (n); i++)
    if ((int)ANS[i].size() > 0) c++;
  printf("%d\n", c);
  for (int i = (0); i < (n); i++) {
    if ((int)ANS[i].size() == 0) continue;
    printf("%d ", (int)ANS[i].size());
    for (int j = (0); j < ((int)ANS[i].size()); j++) printf("%d ", ANS[i][j]);
    printf("\n");
  }
}
