#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, t[N], ans;
set<int> S;
vector<int> SS[N];
map<int, int> nr;
bool inv[N];
int ob;
void dfs(int x) {
  SS[ob].push_back(x);
  inv[x] = 1;
  int y = nr[t[x]];
  if (!inv[y]) dfs(y);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &t[i]);
    S.insert(t[i]);
  }
  int wsk = 0;
  for (set<int>::iterator it = S.begin(); it != S.end(); it++) nr[*it] = ++wsk;
  for (int i = 1; i <= n; i++)
    if (!inv[i]) {
      ans++;
      ob = ans;
      dfs(i);
    }
  printf("%d\n", ans);
  for (int i = 1; i <= ans; i++) {
    printf("%d ", SS[i].size());
    for (int j = 0; j < SS[i].size(); j++) printf("%d ", SS[i][j]);
    printf("\n");
  }
  return 0;
}
