#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long linf = 1e18;
const int N = 100000 + 10;
int n;
long long a[N];
long long b[N];
int pos[N];
bool vis[N];
vector<int> v;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) b[i] = a[i];
  sort(b + 1, b + 1 + n);
  for (int i = 1; i <= n; i++) {
    int l = 1, r = n;
    int mid = 0;
    while (l <= r) {
      mid = (l + r) >> 1;
      if (b[mid] <= a[i]) {
        pos[i] = mid;
        l = mid + 1;
      } else
        r = mid - 1;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      cnt++;
      int j = i;
      for (;;) {
        if (vis[j]) break;
        vis[j] = 1;
        j = pos[j];
      }
    }
  cout << cnt << endl;
  memset(vis, 0, sizeof vis);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      v.clear();
      int j = i;
      for (;;) {
        if (vis[j]) break;
        vis[j] = 1;
        v.push_back(j);
        j = pos[j];
      }
      int sz = v.size();
      cout << sz << " ";
      for (int j = 0; j <= sz - 1; j++) cout << v[j] << " ";
      cout << endl;
    }
  return 0;
}
