#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int n;
int a[100000];
int b[100000];
vector<vector<int>> v;
vector<int> s;
map<int, int> mp;
bool visited[100000];
int ans = 1;
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i], b[i] = a[i], visited[i] = 0;
  sort(a, a + n);
  for (int i = 0; i < n; i++) mp[a[i]] = i;
  for (int i = 0; i < n; i++) {
    s.clear();
    int q = i;
    if (!visited[i]) {
      visited[i] = 1;
      s.push_back(i + 1);
      while (b[mp[b[i]]] != b[i] && !visited[mp[b[i]]]) {
        visited[mp[b[i]]] = 1;
        s.push_back(mp[b[i]] + 1);
        i = mp[b[i]];
      }
      v.push_back(s);
      i = q;
    }
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i].size() << " ";
    for (int j = 0; j < v[i].size(); j++) cout << v[i][j] << " ";
    cout << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
