#include <bits/stdc++.h>
using namespace std;
void input() {
  int n;
  cin >> n;
  int a[n + 1], b[n + 1];
  b[0] = INT_MIN;
  map<int, int> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n + 1);
  for (int i = 1; i <= n; i++) {
    m[b[i]] = i;
  }
  vector<vector<int>> v;
  int first[n + 1];
  memset(first, 0, sizeof(first));
  for (int i = 1; i <= n; i++) {
    if (first[i] == 1) {
      continue;
    }
    if (a[i] != b[i]) {
      vector<int> v1;
      v1.push_back(i);
      int j = m[a[i]];
      first[i] = 1;
      while (j != i) {
        v1.push_back(j);
        first[j] = 1;
        j = m[a[j]];
      }
      v.push_back(v1);
    } else {
      v.push_back({i});
      first[i] = 1;
    }
  }
  cout << v.size() << "\n";
  for (auto it : v) {
    cout << it.size() << " ";
    for (auto it1 : it) {
      cout << it1 << " ";
    }
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  input();
  return 0;
}
