#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int a[MAXN], b[MAXN], pos[MAXN];
map<int, int> zoom;
bool vis[MAXN];
int main() {
  ios::sync_with_stdio(false);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; i++) {
    zoom[b[i]] = i;
    b[i] = i;
  }
  for (int i = 1; i <= n; i++) {
    a[i] = zoom[a[i]];
    pos[a[i]] = i;
  }
  vector<vector<int>> res;
  for (int i = 1; i <= n; i++) {
    if (!vis[pos[i]]) {
      vector<int> cur;
      for (int j = pos[i]; !vis[j]; j = pos[j]) {
        cur.push_back(j);
        vis[j] = true;
      }
      res.push_back(cur);
    }
  }
  cout << res.size() << "\n";
  for (auto v : res) {
    cout << v.size() << " ";
    for (auto x : v) {
      cout << x << " ";
    }
    cout << "\n";
  }
}
