#include <bits/stdc++.h>
using namespace std;
vector<long long int> adj[2000005], ans[2000005];
vector<pair<long long int, long long int> > pp;
long long int ct = 0, vis[2000005];
void dfs(long long int v) {
  vis[v] = 1;
  ans[ct].push_back(v + 1);
  for (auto i : adj[v]) {
    if (vis[i] == 0) {
      dfs(i);
    }
  }
}
void solve() {
  long long int n;
  cin >> n;
  pp.resize(n);
  for (long long int i = 0; i < n; i++) {
    cin >> pp[i].first;
    pp[i].second = i;
  }
  sort(pp.begin(), pp.end());
  for (long long int i = 0; i < n; i++) {
    adj[i].push_back(pp[i].second);
    adj[pp[i].second].push_back(i);
  }
  for (long long int i = 0; i < n; i++) {
    if (vis[i] == 0) {
      dfs(i);
      ct++;
    }
  }
  cout << ct;
  cout << "\n";
  for (auto i = 0; i < ct; i++) {
    cout << (long long int)ans[i].size() << " ";
    for (auto j : ans[i]) {
      cout << j << ' ';
    }
    cout << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  {
    solve();
    cout << "\n";
  }
}
