#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b, long long m) {
  a %= m;
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ((ret % m) * (a % m)) % m;
    a = ((a % m) * (a % m)) % m;
    b >>= 1;
  }
  return ret;
}
map<int, int> m;
vector<int> v, temp;
int vis[100001];
int n;
void dfs(int x) {
  if (vis[x]) return;
  vis[x]++;
  temp.push_back(x);
  dfs(m[v[x]]);
}
int main() {
  cin >> n;
  v.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    m[v[i]]++;
  }
  int count = 0;
  for (auto it : m) {
    m[it.first] = count++;
  }
  vector<vector<int> > ans;
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    dfs(i);
    ans.push_back(temp);
    temp.clear();
  }
  cout << (int)ans.size() << endl;
  for (auto it : ans) {
    cout << it.size() << " ";
    for (auto it1 : it) {
      cout << it1 + 1 << " ";
    }
    cout << endl;
  }
  return 0;
}
