#include <bits/stdc++.h>
using namespace std;
int Y[] = {-1, 1, 0, 0, -1, -1, 1, 1};
int X[] = {0, 0, -1, 1, -1, 1, -1, 1};
int directions = 4;
long long power(long long a, long long n) {
  if (a == 0) return 0;
  if (a == 1 || n == 0) return 1;
  if (n == 1) return a % 1000000007;
  long long t = power(a, n / 2);
  t = t * t % 1000000007;
  if (n & 1) return t * a % 1000000007;
  return t;
}
void keywords() {
  return;
  int x;
  scanf("%d", &x);
  printf("lol");
  cin >> x;
  cout << "lol" << endl;
  while (1) continue;
  while (1) break;
}
int popcount(long long a) {
  int c = 0;
  while (a) {
    c++;
    a -= a & -a;
  }
  return c;
}
void factorize(int a) {}
void update(int tree[], int idx, int val, int maxval) {
  for (; idx <= maxval; idx += idx & -idx) {
    tree[idx] += val;
  }
}
int read(int tree[], int idx) {
  long long sum = 0;
  for (; idx > 0; idx -= idx & -idx) {
    sum += tree[idx];
  }
  return sum;
}
struct node2 {
  int id, val;
  node2() {
    static int ctx = 1;
    id = ctx++;
  };
  node2(int a, int b = 0, int c = 0, int d = 0, int e = 0, int f = 0) {
    val = a;
  }
};
struct comp2 {
  bool operator()(int a, int b) { return b < a; }
};
bool cmp2(int a, int b) { return b < a; }
struct node {
  int id, val;
  node() {
    static int ctx = 0;
    id = ctx++;
  };
  node(int a, int b = 0, int c = 0, int d = 0, int e = 0, int f = 0) {
    val = a;
  }
};
struct comp {
  bool operator()(int a, int b) { return b < a; }
};
bool cmp(node a, node b) { return a.val < b.val; }
int n, m, b, c, d, k, w, x, y, q, t, ans, res, ma, mi, T, act = 0, pas = 1, cur,
                                                          flag, now;
int uu, vv, ww, l, r;
int dp, dp2, cnt;
char s[1];
node a[100009], p;
bool h[100009];
double f, z, e;
vector<int> v[100009], vec;
set<int> sett;
map<int, int> mapp;
void print() {}
void print2() {}
void input() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i < n + 1; i++) cin >> a[i].val;
}
void init() {}
void solve() {
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i < n + 1; i++) {
    if (h[i] == false)
      c++;
    else
      continue;
    while (a[i].id != i) {
      h[a[i].id] = true;
      v[c].push_back(a[i].id);
      p = a[a[i].id];
      a[a[i].id] = a[i];
      a[i] = p;
    }
    h[a[i].id] = true;
    v[c].push_back(a[i].id);
  }
}
void output() {
  cout << c << endl;
  for (int i = 1; i < c + 1; i++) {
    cout << v[i].size() << " ";
    for (auto u : v[i]) cout << u << " ";
    cout << endl;
  }
}
int main() {
  input();
  solve();
  output();
  return 0;
}
