#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 1, MAXX = 1e9 + 1;
int n, a[MAXN];
map<int, int> dp, id;
signed main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; ++i) {
    if (dp[a[i]] < dp[a[i] - 1] + 1) {
      dp[a[i]] = dp[a[i] - 1] + 1;
      id[a[i]] = i;
    }
  }
  int MAX = INT_MIN, maxid;
  map<int, int>::iterator itr;
  for (itr = dp.begin(); itr != dp.end(); ++itr) {
    if (MAX < itr->second) {
      MAX = itr->second;
      maxid = itr->first;
    }
  }
  cout << MAX << endl;
  int pal = maxid;
  vector<int> ans;
  for (int i = n; i >= 1; --i) {
    if (pal == maxid - MAX) break;
    if (pal == a[i]) {
      pal--;
      ans.push_back(i);
    }
  }
  for (int i = int(ans.size()) - 1; i >= 0; --i) {
    cout << ans[i] << " ";
  }
}
