#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
const int INF = 2e9 + 5;
const long long LINF = 1e18 + 5;
const long long MOD = 1e9 + 7;
const int MAX = 1e5 + 5;
int a[MAX];
vector<int> ad[MAX];
int used[MAX];
vector<int> res[MAX];
vector<pair<int, int> > v;
void dfs(int u, int color) {
  res[color].push_back(u);
  used[u] = 1;
  for (int i = 0; i < ad[u].size(); ++i) {
    int w = ad[u][i];
    if (!used[w]) {
      dfs(w, color);
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    v.push_back(make_pair(a[i], i));
  }
  sort((v).begin(), (v).end());
  for (int i = 0; i < n; ++i) {
    pair<int, int> t = v[i];
    if (t.second == i) continue;
    int tt = t.second;
    ad[tt].push_back(i);
    ad[i].push_back(tt);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      dfs(i, ans);
      ++ans;
    }
  }
  printf("%d\n", ans);
  for (int i = 0; i < ans; ++i) {
    printf("%d", int(res[i].size()));
    for (int j = 0; j < int(res[i].size()); ++j) {
      printf(" %d", res[i][j] + 1);
    }
    printf("\n");
  }
  return 0;
}
