#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const long long int N = 1e5 + 3;
long long int mod = 1e9 + 7;
long long int vis[N], tik[N];
vector<long long int> ans[N], alfa[N];
long long int k;
void dfs(long long int u) {
  vis[u] = 1;
  for (auto to : alfa[u]) {
    if (!vis[to]) {
      ans[k].push_back(to);
      dfs(to);
    }
  }
}
void solve() {
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int> > vp;
  vector<long long int> v(n, 0), wyn(n, 0);
  for (long long int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    v.push_back(x);
    vp.push_back({x, i});
  }
  sort((vp).begin(), (vp).end());
  for (long long int i = 0; i < (long long int)vp.size(); i++) {
    long long int yo = vp[i].second;
    alfa[i + 1].push_back(yo + 1);
    alfa[yo + 1].push_back(i + 1);
  }
  k = 1;
  for (long long int i = 1; i <= n; i++) {
    if (!vis[i]) {
      ans[k].push_back(i);
      dfs(i);
      k++;
    }
  }
  cout << k - 1 << "\n";
  for (long long int i = 1; i < k; i++) {
    cout << ans[i].size() << " ";
    for (auto to : ans[i]) cout << to << " ";
    cout << "\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  while (t--) solve();
  return 0;
}
