#include <bits/stdc++.h>
using namespace std;
long long expo(long long x, long long n, long long m) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return expo((x * x) % m, n / 2, m);
  else
    return (x * expo((x * x) % m, (n - 1) / 2, m)) % m;
}
string DtoB(int j) {
  string s = "";
  for (int i = 32; i >= 0; i--) {
    int k = j >> i;
    if (k & 1)
      s += "1";
    else
      s += "0";
  }
  return s;
}
void solve() {
  int n;
  cin >> n;
  int arr[n];
  int s[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    s[i] = arr[i];
  }
  sort(s, s + n);
  map<int, int> m;
  for (int i = 0; i < n; i++) m[s[i]] = i;
  vector<vector<int> > ans;
  int visit[n];
  memset(visit, 0, sizeof(visit));
  ;
  for (int i = 0; i < n; i++) {
    if (visit[i] == 0) {
      vector<int> p;
      for (int j = i; visit[j] == 0; j = m[arr[j]]) {
        p.push_back(j + 1);
        visit[j] = 1;
      }
      ans.push_back(p);
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].size() << " ";
    for (int j = 0; j < ans[i].size(); j++) cout << ans[i][j] << " ";
    cout << endl;
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}
