#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e18, M = 1e9 + 7;
const long long int N = 1e5 + 5;
map<long long int, long long int> pos;
vector<long long int> v[N], tmp, mark, a, b;
vector<vector<long long int>> ans;
void dfs(long long int x) {
  mark[x] = 1;
  tmp.push_back(x);
  for (auto u : v[x]) {
    if (!mark[u]) dfs(u);
  }
}
void solve() {
  long long int n;
  cin >> n;
  a = b = vector<long long int>(n);
  for (long long int i = 0; i < n; ++i) cin >> a[i], b[i] = a[i];
  sort(b.begin(), b.end());
  for (long long int i = 0; i < n; ++i) pos[b[i]] = i;
  for (long long int i = 0; i < n; ++i) {
    if (a[i] != pos[a[i]]) v[i].push_back(pos[a[i]]);
  }
  mark = vector<long long int>(n, 0);
  for (long long int i = 0; i < n; ++i) {
    if (!mark[i]) {
      tmp.clear();
      dfs(i);
      ans.push_back(tmp);
    }
  }
  cout << ans.size() << "\n";
  for (auto x : ans) {
    cout << x.size() << " ";
    for (auto u : x) cout << u + 1 << " ";
    cout << "\n";
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
