#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
struct uf {
  static const int MAXN = 1e5 + 10;
  int par[MAXN];
  int size[MAXN];
  void init() {
    memset(par, -1, sizeof(par));
    for (int i = 0; i < (MAXN); ++i) size[i] = 1;
  }
  int root(int a) {
    if (par[a] == -1) return a;
    return par[a] = root(par[a]);
  }
  void unite(int a, int b) {
    a = root(a);
    b = root(b);
    if (a == b) return;
    if (size[a] < size[b]) swap(a, b);
    par[b] = a;
    size[a] += size[b];
  }
  bool same(int a, int b) { return root(a) == root(b); }
};
uf u;
void solve() {
  u.init();
  long long n;
  cin >> n;
  map<long long, long long> mp;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]] = i;
  }
  sort(a.begin(), a.end());
  for (long long i = 0; i < n; i++) {
    u.unite(mp[a[i]], i);
  }
  long long res = 0;
  vector<long long> g[100009];
  for (long long i = 0; i < n; i++) {
    if (u.par[i] == -1) res++;
    g[u.root(i)].push_back(i);
  }
  cout << res << "\n";
  for (long long i = 0; i < n; i++) {
    if (u.par[i] == -1) {
      cout << g[i].size() << " ";
      for (auto j : g[i]) cout << j + 1 << " ";
      cout << "\n";
    }
  }
}
int main() {
  int t;
  t = 1;
  while (t--) solve();
}
