#include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
namespace std {
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& a) {
  out << '(' << a.first << ',' << a.second << ')';
  return out;
}
}  // namespace std
int n;
int ar[100005];
int br[100005];
bool vis[100005];
int main() {
  cin >> n;
  for (int i = 0; i < (n); ++i) cin >> ar[i], br[i] = ar[i];
  sort(br, br + n);
  for (int i = 0; i < (n); ++i) ar[i] = lower_bound(br, br + n, ar[i]) - br;
  vector<vector<int> > ans;
  for (int i = 0; i < (n); ++i)
    if (!vis[i]) {
      int cur = i;
      vector<int> res;
      while (!vis[cur]) {
        vis[cur] = 1;
        res.push_back(cur);
        cur = ar[cur];
      }
      ans.push_back(res);
    }
  cout << ans.size() << endl;
  for (auto res : ans) {
    sort((res).begin(), (res).end());
    printf("%d", (int)res.size());
    for (auto e : res) printf(" %d", e + 1);
    puts("");
  }
  return 0;
}
