#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
pair<int, int> ara[100005];
vector<int> ad[100005], comp[100005];
int cnt = 0;
bool vis[100005];
void dfs(int src) {
  vis[src] = true;
  comp[cnt].push_back(src);
  for (int i = 0; i < ad[src].size(); i++) {
    int v = ad[src][i];
    if (!vis[v]) {
      dfs(v);
    }
  }
}
int main() {
  int n, i, j, arr[100005];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    mp[arr[i]] = i;
    ara[i].first = arr[i];
    ara[i].second = i;
  }
  sort(ara, ara + n);
  for (i = 0; i < n; i++) {
    ad[mp[arr[i]]].push_back(mp[ara[i].first]);
    ad[mp[ara[i].first]].push_back(mp[arr[i]]);
  }
  for (i = 0; i < n; i++) {
    if (!vis[i]) {
      dfs(i);
      cnt++;
    }
  }
  printf("%d\n", cnt);
  for (i = 0; i < cnt; i++) {
    printf("%d ", comp[i].size());
    for (j = 0; j < comp[i].size(); j++) {
      printf("%d ", comp[i][j] + 1);
    }
    printf("\n");
  }
  return 0;
}
