#include <bits/stdc++.h>
using namespace std;
const int max_n = 100011, log_n = 32, max_m = 111, mod = 1000000007,
          inf = 1000111222;
int n, a[max_n], b[max_n], used[max_n];
vector<vector<int> > ans;
map<int, int> mm;
void dfs(int x, vector<int> &res) {
  used[x] = 1;
  res.push_back(x + 1);
  if (!used[mm[a[x]]]) {
    dfs(mm[a[x]], res);
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  for (int i = 0; i < n; ++i) {
    mm[b[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      vector<int> res;
      dfs(i, res);
      ans.push_back(res);
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i].size() << " ";
    for (int q = 0; q < ans[i].size(); ++q) {
      cout << ans[i][q] << " ";
    }
    cout << endl;
  }
  return 0;
}
