#include <bits/stdc++.h>
using namespace std;
map<long long, long long> pos;
vector<long long> v[100002];
long long A[100002], B[100002];
bool check[100002];
int main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) scanf("%lld", &A[i]), pos[A[i]] = i;
  for (long long i = 0; i < n; i++) B[i] = A[i];
  sort(B, B + n);
  long long cnt = 0;
  for (long long i = 0; i < n; i++) {
    if (check[i]) continue;
    long long p = pos[B[i]];
    while (!check[p]) {
      check[p] = true;
      long long x = B[p];
      v[cnt].push_back(p);
      p = pos[x];
    }
    cnt++;
  }
  cout << cnt << endl;
  for (long long i = 0; i < cnt; i++) {
    cout << v[i].size() << " ";
    for (long long j = 0; j < v[i].size(); j++) cout << v[i][j] + 1 << " ";
    printf("\n");
  }
}
