#include <bits/stdc++.h>
using namespace std;
int n;
long long A[200200];
long long B[200200];
long long C[200200];
bool Visited[200200];
vector<vector<long long> > Ans;
vector<long long> TT;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> A[i], B[i] = A[i];
  sort(B + 1, B + n + 1);
  for (int i = 1; i <= n; i++) {
    auto it = lower_bound(B + 1, B + n + 1, A[i]) - (B);
    C[i] = it;
  }
  for (int i = 1; i <= n; i++) {
    if (Visited[i]) continue;
    long long Temp = i;
    long long t = i;
    long long Last = -1;
    while (!Visited[Temp]) {
      Visited[Temp] = true;
      Temp = C[Temp];
      TT.push_back(Temp);
    }
    Ans.push_back(TT);
    TT.clear();
  }
  cout << Ans.size();
  cout << endl;
  for (int i = 0; i < Ans.size(); i++) {
    cout << Ans[i].size() << " ";
    reverse(Ans[i].begin(), Ans[i].end());
    for (int j = 0; j < Ans[i].size(); j++) cout << Ans[i][j] << " ";
    cout << endl;
  }
}
