#include <bits/stdc++.h>
using namespace std;
int arr[100010];
set<int> seet;
vector<int> temp;
vector<vector<int>> ans;
set<int>::iterator it;
map<int, int> mp;
map<int, int> compress;
int t[100010];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &t[i]);
    arr[i] = t[i];
  }
  sort(t + 1, t + n + 1);
  for (int i = 1; i <= n; ++i) compress[t[i]] = i;
  for (int i = 1; i <= n; ++i) {
    arr[i] = compress[arr[i]];
    mp[arr[i]] = i;
    seet.insert(arr[i]);
  }
  for (int i = 1; i <= n; ++i) {
    it = seet.find(i);
    if (it != seet.end()) {
      temp.push_back(arr[i]);
      int s = i;
      int idx = i;
      seet.erase(arr[i]);
      int to = arr[arr[idx]];
      if (arr[i] != to) {
        while (!seet.empty()) {
          seet.erase(to);
          temp.push_back(to);
          if (to == s)
            break;
          else
            to = arr[to];
        }
      }
      ans.push_back(temp);
      temp.clear();
    }
  }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) {
    printf("%d ", ans[i].size());
    for (int j = 0; j < ans[i].size(); ++j) {
      printf("%d ", mp[ans[i][j]]);
    }
    printf("\n");
  }
}
