#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.emplace_back(x);
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\n';
  err(++it, args...);
}
const int maxN = 112345;
vector<int> edges[maxN];
bool visited[maxN];
vector<vector<int>> res;
void dfs(int u) {
  visited[u] = true;
  res[res.size() - 1].push_back(u);
  for (int v : edges[u]) {
    if (visited[v]) continue;
    dfs(v);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<pair<int, int>> t;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    t.emplace_back(a, i);
  }
  sort(t.begin(), t.end());
  for (int i = 0; i < n; i++) {
    pair<int, int> a = t[i];
    edges[i].push_back(a.second);
  }
  for (int i = 0; i < n; i++) {
    if (visited[i] == false) {
      vector<int> t;
      res.push_back(t);
      dfs(i);
    }
  }
  cout << res.size() << '\n';
  for (int i = 0; i < res.size(); i++) {
    vector<int> temp = res[i];
    cout << temp.size() << " ";
    for (int i : temp) cout << i + 1 << " ";
    cout << '\n';
  }
  return 0;
}
