#include <bits/stdc++.h>
using namespace std;
long long n, m, ans;
vector<long long> a;
vector<long long> AdjList[100005];
long long visited[100005];
unordered_map<long long, long long> mp, mp2;
vector<vector<long long>> comp;
long long numOfComp;
void dfs(long long u) {
  if (visited[u]++) return;
  comp[numOfComp].push_back(u);
  dfs(AdjList[u][0]);
}
int main() {
  cin >> n;
  a.push_back(-1000000005);
  for (int i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    a.push_back(x);
  }
  vector<long long> b = a;
  sort(b.begin(), b.end());
  for (int i = 1; i <= n; i++) {
    mp[b[i]] = i;
  }
  b = a;
  for (int i = 1; i <= n; i++) {
    b[i] = mp[a[i]];
  }
  for (int i = 1; i <= n; i++) {
    AdjList[b[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    if (!visited[i]) {
      comp.push_back({});
      dfs(i);
      numOfComp++;
    }
  }
  cout << comp.size() << endl;
  for (auto ve : comp) {
    cout << ve.size() << " ";
    for (auto x : ve) cout << x << " ";
    cout << endl;
  }
}
