#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[100010];
vector<int> v;
vector<int> ans[100010];
int k = 0;
bool u[100010];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    v.push_back(a[i]);
  }
  sort(v.begin(), v.end());
  for (int i = 1; i <= n; i++) {
    a[i] = lower_bound(v.begin(), v.end(), a[i]) - v.begin() + 1;
  }
  for (int i = 1; i <= n; i++) {
    if (!u[a[i]]) {
      int x = i;
      k++;
      while (!u[a[x]]) {
        u[a[x]] = 1;
        ans[k].push_back(x);
        x = a[x];
      }
    }
  }
  cout << k << endl;
  for (int i = 1; i <= k; i++) {
    cout << ans[i].size() << " ";
    for (int j = 0; j < ans[i].size(); j++) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
