#include <bits/stdc++.h>
using namespace std;
int a[100005], b[100005];
bool vis[100005];
vector<int> adj[100005], v;
vector<vector<int> > ans;
void dfs(int s) {
  if (vis[s]) return;
  v.push_back(s);
  vis[s] = 1;
  for (int i = 0; i < adj[s].size(); i++) {
    dfs(adj[s][i]);
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  for (int i = 0; i < n; i++) {
    int ix = lower_bound(b, b + n, a[i]) - b;
    adj[i].push_back(ix);
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      v.clear();
      dfs(i);
      ans.push_back(v);
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    int l = ans[i].size();
    cout << l << " ";
    for (int j = 0; j < l; j++) {
      cout << ans[i][j] + 1 << " ";
    }
    cout << endl;
  }
  return 0;
}
