#include <bits/stdc++.h>
using namespace std;
const long long Maxn = 1e5 + 1, Mod = 1e9 + 7;
const long long N = 100010;
std::vector<long long> dsu(N);
long long root(long long a) {
  if (a == dsu[a]) return a;
  a = dsu[dsu[a]];
  return a;
}
void update(long long x, long long y) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  dsu[x] = y;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n;
  cin >> n;
  vector<pair<long long, long long>> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i].first, v[i].second = i;
  sort(v.begin(), v.end());
  vector<long long> r(n);
  for (long long i = 0; i < n; i++) r[i] = v[i].second;
  vector<vector<long long>> res;
  vector<long long> vis(n, 0);
  for (long long i = 0; i < n; i++) {
    if (vis[i]) continue;
    std::vector<long long> st;
    long long x = i;
    while (!vis[x]) {
      vis[x] = 1;
      st.push_back(x);
      x = r[x];
    }
    res.push_back(st);
  }
  cout << res.size() << "\n";
  for (auto x : res) {
    cout << x.size() << " ";
    for (auto y : x) cout << y + 1 << " ";
    cout << "\n";
  }
  return 0;
}
