#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10, MAXL = 20, inf = 1e18 + 1;
long long n;
pair<int, int> arr[N];
vector<int> g[N], ans;
bool vis[N];
void dfs(int v) {
  ans.push_back(v);
  vis[v] = true;
  for (int i : g[v])
    if (!vis[i]) dfs(i);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    arr[i] = {a, i};
  }
  sort(arr, arr + n);
  for (int i = 0; i < n; i++) {
    g[i].push_back(arr[i].second);
  }
  int res = 0;
  for (int i = 0; i < n; i++)
    if (!vis[i]) {
      int si = 0;
      dfs(i);
      res++;
    }
  fill(vis, vis + n, 0);
  cout << res << endl;
  for (int i = 0; i < n; i++)
    if (!vis[i]) {
      int si = 0;
      ans.clear();
      dfs(i);
      cout << ans.size() << ' ';
      for (int j : ans) cout << j + 1 << ' ';
      cout << endl;
    }
}
