#include <bits/stdc++.h>
long long int mod = 1000000007;
using namespace std;
vector<vector<int> > g(100001);
int vis[100001];
vector<vector<int> > com;
void dfs(int x, vector<int> &tmp) {
  vis[x] = 1;
  for (int i = 0; i < g[x].size(); i++) {
    if (vis[g[x][i]] == 0) {
      tmp.push_back(g[x][i]);
      dfs(g[x][i], tmp);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n, x;
  cin >> n;
  pair<int, int> arr[n + 1];
  pair<int, int> tmp[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> x;
    arr[i].first = x;
    arr[i].second = i;
    tmp[i] = arr[i];
  }
  sort(tmp + 1, tmp + n + 1);
  for (int i = 1; i < n; i++) {
    if (arr[i].first != tmp[i].first) {
      g[arr[i].second].push_back(tmp[i].second);
      g[tmp[i].second].push_back(arr[i].second);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (vis[i] == 0) {
      vector<int> tmp;
      tmp.push_back(i);
      dfs(i, tmp);
      com.push_back(tmp);
    }
  }
  cout << com.size() << endl;
  for (int i = 0; i < com.size(); i++) {
    cout << com[i].size() << " ";
    for (int j = 0; j < com[i].size(); j++) {
      cout << com[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
