#include <bits/stdc++.h>
using namespace std;
int a[100010], b[100010];
int pos[100010], book[100010];
vector<int> ans[100010];
int main() {
  int n;
  cin >> 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++) pos[i] = lower_bound(b, b + n, a[i]) - b;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (book[i]) continue;
    int j = pos[i];
    book[i] = 1;
    ans[cnt].push_back(i);
    while (!book[j]) ans[cnt].push_back(j), book[j] = 1, j = pos[j];
    cnt++;
  }
  cout << cnt << endl;
  for (int i = 0; i < cnt; i++) {
    printf("%d", ans[i].size());
    for (int j = 0; j < ans[i].size(); j++) printf(" %d", ans[i][j] + 1);
    cout << endl;
  }
  return 0;
}
