#include <bits/stdc++.h>
using namespace std;
int dcmp(long double n, long double y) {
  return fabs(n - y) <= 1e-9 ? 0 : n < y ? -1 : 1;
}
const int N = 1e5 + 10;
const long long MOD = 998244353;
map<long long, long long> in;
bool vis[N];
pair<int, int> a[N];
vector<vector<int> > ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n); ++i) {
    cin >> a[1 + i].first;
    a[i + 1].second = i + 1;
  }
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      vector<int> temp;
      int cur = i;
      while (!vis[cur]) {
        temp.push_back(cur);
        vis[cur] = 1;
        cur = a[cur].second;
      }
      ans.push_back(temp);
    }
  }
  cout << ans.size() << '\n';
  for (int i = 0; i < ((int)((ans).size())); ++i) {
    cout << ans[i].size() << ' ';
    for (int j = 0; j < ((int)((ans[i]).size())); ++j) {
      cout << ans[i][j] << ' ';
    }
    cout << '\n';
  }
}
