#include <bits/stdc++.h>
using namespace std;
int i, j, temp;
vector<int> b, v[100002], ans[100002];
int vis[100002];
map<int, int> m;
set<int> s;
void dfs(int u) {
  if (vis[u]) return;
  vis[u] = 1;
  for (auto x : v[u]) {
    s.insert(x);
    dfs(x);
  }
}
void solve() {
  int n;
  cin >> n;
  for (i = 1; i < n + 1; i++) {
    cin >> temp;
    m[temp] = i;
    b.push_back(temp);
  }
  sort(b.begin(), b.end());
  for (i = 1; i < n + 1; i++) {
    v[i].push_back(m[b[i - 1]]);
    v[m[b[i - 1]]].push_back(i);
  }
  int k = 0;
  for (i = 1; i < n + 1; i++) {
    if (vis[i]) continue;
    s.clear();
    dfs(i);
    for (auto x : s) {
      ans[k].push_back(x);
    }
    k++;
  }
  cout << k << endl;
  for (i = 0; i < k; i++) {
    cout << ans[i].size() << " ";
    for (auto x : ans[i]) {
      cout << x << " ";
    }
    cout << endl;
  }
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
