#include <bits/stdc++.h>
using namespace std;
long double EPS = 1e-9;
long long cel(long long a, int b) { return ((a - 1) / b + 1); }
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  return (b == 0) ? a : gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
vector<int> vis(100007, 0);
vector<int> adj[100007];
vector<int> ans[100007];
void dfs(int x, int i) {
  vis[x] = 1;
  ans[i].push_back(x + 1);
  for (int t : adj[x]) {
    if (vis[t] == 1) continue;
    dfs(t, i);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, y = 0;
  cin >> n;
  vector<int> v(n), v1(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    v1[i] = v[i];
  }
  sort(v1.begin(), v1.end());
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    m[v1[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    adj[i].push_back(m[v[i]]);
    adj[m[v[i]]].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    if (vis[i] == 1) continue;
    dfs(i, y);
    y++;
  }
  cout << y << '\n';
  for (int i = 0; i < y; i++) {
    cout << ans[i].size() << " ";
    for (int t : ans[i]) {
      cout << t << " ";
    }
    cout << "\n";
  }
  return 0;
}
