#include <bits/stdc++.h>
using namespace std;
int edges[100000 + 7];
bool done[100000 + 7];
vector<int> w;
void dfs(int c) {
  w.push_back(c);
  done[c] = 1;
  if (!done[edges[c]]) dfs(edges[c]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n];
  int b[n];
  map<int, int> m;
  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) m[b[i]] = i;
  for (int i = 0; i < n; ++i) edges[i] = m[a[i]];
  vector<vector<int>> v;
  for (int i = 0; i < n; ++i)
    if (!done[i]) {
      w.clear();
      dfs(i);
      v.push_back(w);
    }
  cout << (int)(v).size() << "\n";
  for (auto i : v) {
    cout << (int)(i).size() << " ";
    for (int j : i) cout << j + 1 << " ";
    cout << "\n";
  }
  return 0;
}
