#include <bits/stdc++.h>
using namespace std;
int n, i, j, k, p, q;
pair<int, int> a[100007];
vector<vector<int> > ans;
bool vis[100007];
void dfs(int x, vector<int> &ans) {
  if (vis[x]) return;
  ans.push_back(x);
  vis[x] = 1;
  dfs(a[x].second, ans);
}
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  sort(a + 1, a + n + 1);
  for (i = 1; i <= n; i++) {
    if (vis[a[i].second] == 0) {
      ans.push_back(vector<int>());
      dfs(a[i].second, ans.back());
    }
  }
  cout << ans.size() << endl;
  for (i = 0; i < ans.size(); i++) {
    cout << ans[i].size() << " ";
    for (j = 0; j < ans[i].size(); j++) cout << ans[i][j] << " ";
    cout << endl;
  }
}
