#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 1e5 + 5;
vector<long long int> adj[maxn];
vector<long long int> jvb[maxn];
bool mark[maxn];
long long int a[maxn], b[maxn];
map<long long int, long long int> mp;
long long int k = 0;
void DFS(long long int x, long long int c) {
  mark[x] = true;
  jvb[c].push_back(x);
  for (auto y : adj[x]) {
    if (mark[y] == 1) continue;
    DFS(y, c);
  }
}
int main() {
  long long int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
    mp[a[i]] = i;
  }
  sort(b, b + n);
  for (int i = 0; i < n; i++) {
    adj[mp[b[i]]].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    if (mark[i] == 0) {
      k++;
      DFS(i, k);
    }
  }
  cout << k;
  for (int i = 1; i <= k; i++) {
    cout << '\n' << jvb[i].size() << ' ';
    for (auto y : jvb[i]) cout << y + 1 << ' ';
  }
}
