#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int maxn = 2e5 + 5;
map<int, int> dp, pos;
int pre[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int i, j, k, m, n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> k;
    if (!dp.count(k - 1)) {
      dp[k] = 1;
      pre[i] = -1;
      pos[k] = i;
    } else if (dp[k - 1] + 1 > dp[k]) {
      dp[k] = dp[k - 1] + 1;
      pos[k] = i;
      pre[i] = pos[k - 1];
    }
  }
  pair<int, int> mst = {0, 0};
  for (auto it : dp) {
    if (it.second > mst.second) {
      mst.first = it.first;
      mst.second = it.second;
    }
  }
  int npos = pos[mst.first];
  vector<int> ans;
  while (npos != -1) {
    ans.push_back(npos);
    npos = pre[npos];
  }
  reverse(ans.begin(), ans.end());
  cout << ans.size() << endl;
  for (auto it : ans) cout << it << " ";
  return 0;
}
