#include <bits/stdc++.h>
using namespace std;
vector<long long> g;
int main() {
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  g.resize(n);
  long long a[n], b[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  map<long long, long long> mp;
  for (long long i = 0; i < n; i++) {
    mp[b[i]] = i;
  }
  for (long long i = 0; i < n; i++) {
    g[i] = mp[a[i]];
  }
  vector<bool> visited(n, 0);
  vector<vector<long long> > main_ans;
  for (long long i = 0; i < n; i++) {
    vector<long long> ans;
    if (!visited[i]) {
      visited[i] = 1;
      long long t = g[i];
      ans.push_back(i + 1);
      while (t != i) {
        visited[t] = 1;
        ans.push_back(t + 1);
        t = g[t];
      }
    }
    if ((long long)(ans.size()) > 0) {
      main_ans.push_back(ans);
    }
  }
  cout << (long long)(main_ans.size()) << "\n";
  for (long long i = 0; i < (long long)(main_ans.size()); i++) {
    cout << (long long)(main_ans[i].size()) << " ";
    for (long long j = 0; j < (long long)(main_ans[i].size()); j++) {
      cout << main_ans[i][j] << " ";
    }
    cout << "\n";
  }
}
