#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  long long arr[n], brr[n];
  map<long long, int> m;
  for (long long i = 0; i < n; ++i) {
    cin >> arr[i];
    brr[i] = arr[i];
    m[arr[i]] = i;
  }
  sort(brr, brr + n);
  vector<vector<int> > vec;
  bool mark[n];
  memset(mark, false, sizeof(mark));
  for (long long i = 0; i < n; ++i) {
    int temp = i;
    vector<int> vec1;
    if (!mark[temp]) {
      vec1.push_back(temp + 1);
      mark[temp] = true;
    }
    while (arr[temp] != brr[temp]) {
      int index = m[brr[temp]];
      swap(arr[temp], arr[index]);
      m[arr[temp]] = temp;
      m[arr[index]] = index;
      if (!mark[index]) {
        vec1.push_back(index + 1);
        mark[index] = true;
      }
      temp = index;
    }
    if (vec1.size() > 0) vec.push_back(vec1);
  }
  int si = vec.size();
  cout << si << "\n";
  for (long long i = 0; i < si; ++i) {
    int si1 = vec[i].size();
    cout << si1 << " ";
    for (long long j = 0; j < si1; ++j) {
      cout << vec[i][j] << " ";
    }
    cout << ""
         << "\n";
  }
}
int main() {
  bool testing = false;
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (testing) {
    freopen("test.txt", "rt", stdin);
    int start = clock();
    solve();
    int end = clock();
    cout << "time: " << (end - start) / (double)(CLOCKS_PER_SEC)*1000
         << " milliseconds\n";
  } else {
    solve();
  }
}
