#include <bits/stdc++.h>
using namespace std;
int n;
bool used[100001];
bool used2[100001];
vector<pair<int, int> > a(100100, {1000000001, 1000000001});
vector<int> c(100001);
int k;
vector<int> res;
void gogo(int x) {
  used[x] = true;
  res.push_back(x + 1);
  k++;
  if (used[a[x].second] == false) {
    gogo(a[x].second);
  }
}
void zan() {
  for (int i = 0; i <= n; i++) {
    used[i] = false;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    c[i] = a[i].first;
    a[i].second = i;
  }
  sort(a.begin(), a.end());
  int res2(0);
  for (int i = 0; i < n; i++) {
    if (a[i].first == c[i] and used[a[i].second] == false) {
      res2++;
    } else {
      k = 0;
      if (used[i] == false) {
        gogo(i);
      }
      if (k != 0) {
        res2++;
        res.clear();
      }
    }
  }
  cout << res2 << "\n";
  zan();
  for (int i = 0; i < n; i++) {
    if (a[i].first == c[i] and used[a[i].second] == false) {
      cout << 1 << " " << i + 1 << "\n";
    } else {
      k = 0;
      if (used[i] == false) {
        gogo(i);
      }
      if (k != 0) {
        cout << k << " ";
        for (int i = 0; i < res.size(); i++) {
          cout << res[i] << " ";
        }
        cout << "\n";
        res.clear();
      }
    }
  }
}
