#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
map<int, pair<int, int> > dp;
int a[N], par[N];
int main() {
  int n;
  scanf("%d", &n);
  int mx = 0, start;
  for (int i = 0, x; i < n; ++i) {
    scanf("%d", &a[i]);
    x = a[i];
    if (!dp.count(x - 1)) {
      dp[x] = {1, i};
      par[i] = i;
    } else {
      if (dp.count(x)) {
        if (dp[x].first < dp[x - 1].first + 1) dp[x] = {dp[x - 1].first + 1, i};
      } else
        dp[x] = {dp[x - 1].first + 1, i};
      par[i] = dp[x - 1].second;
    }
    if (dp[x].first > mx) {
      mx = dp[x].first;
      start = i;
    }
  }
  int id = start;
  vector<int> out;
  while (id != par[id]) {
    out.push_back(id);
    id = par[id];
  }
  out.push_back(id);
  reverse(out.begin(), out.end());
  printf("%d\n", (int)out.size());
  for (int id : out) printf("%d ", id + 1);
}
