#include <bits/stdc++.h>
using namespace std;
vector<int> arr[100005];
map<int, int> mp;
map<int, int> visit;
vector<int> v;
vector<int> sorted;
vector<int> ans;
int solve(int idx, int counter) {
  if (visit[idx] == 1) return counter - 1;
  ans.push_back(idx);
  visit[idx] = 1;
  return solve(mp[v[idx]], counter + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, num;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> num;
    v.push_back(num);
    sorted.push_back(num);
  }
  sort(sorted.begin(), sorted.end());
  for (int i = 0; i < n; ++i) {
    mp[sorted[i]] = i;
  }
  int counter = 0, seq = 0;
  for (int i = 0; i < n; ++i) {
    if (visit[i] == 0) {
      if (i == mp[v[i]]) {
        visit[i] = 1;
        arr[seq].push_back(1);
        arr[seq].push_back(i + 1);
        ++seq;
      } else {
        counter = solve(i, 1);
        arr[seq].push_back(counter);
        for (int j = 0; j < counter; ++j) {
          arr[seq].push_back(ans[j] + 1);
        }
        ans.clear();
        ++seq;
      }
    }
  }
  cout << seq << endl;
  for (int i = 0; i < seq; ++i) {
    cout << arr[i][0] << " ";
    for (int j = 1; j <= arr[i][0]; ++j) {
      if (j > 1) cout << " ";
      cout << arr[i][j];
    }
    cout << endl;
  }
  return 0;
}
