#include <bits/stdc++.h>
using namespace std;
const long long int M = 1e6 + 5, M2 = 2e6, SM = 600;
const long long int inf = 1e18, mod = 98765431;
const long long int LG = 18;
const long long int Z = 26;
long long int n;
long long int jay[M];
long long int ar[M];
basic_string<long long int> g[M];
basic_string<long long int> mol[M];
long long int mark[M];
void dfs(long long int x, long long int c) {
  mark[x] = 1;
  mol[c] += x;
  for (long long int y : g[x]) {
    if (mark[y]) continue;
    dfs(y, c);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  iota(jay, jay + n, 0);
  sort(jay, jay + n,
       [](long long int i, long long int j) { return ar[i] < ar[j]; });
  for (long long int i = 0; i < n; i++) {
    g[i] += jay[i];
    g[jay[i]] += i;
  }
  long long int c = 0;
  for (long long int i = 0; i < n; i++) {
    if (!mark[i]) dfs(i, ++c);
  }
  cout << c << '\n';
  for (long long int i = 1; i < c + 1; i++) {
    cout << ((long long int)mol[i].size()) << ' ';
    for (long long int x : mol[i]) cout << x + 1 << ' ';
    cout << '\n';
  }
}
