#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
pair<int, int> arr[N];
int old[N];
bool got[N];
vector<vector<int> > ans;
vector<int> r;
int main() {
  ios::sync_with_stdio(false);
  int n, i, j, x;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> arr[i].first;
    arr[i].second = i;
  }
  sort(arr, arr + n);
  for (i = 0; i < n; i++) {
    old[i] = arr[i].second;
  }
  for (i = 0; i < n; i++) {
    if (got[i]) {
      continue;
    }
    x = i;
    r.clear();
    while (!got[x]) {
      got[x] = true;
      r.push_back(x);
      x = old[x];
    }
    ans.push_back(r);
  }
  int k = ans.size(), m;
  cout << k << "\n";
  for (i = 0; i < k; i++) {
    m = ans[i].size();
    cout << m << " ";
    for (j = 0; j < m; j++) {
      cout << (ans[i][j] + 1) << " ";
    }
    cout << "\n";
  }
  return 0;
}
