#include <bits/stdc++.h>
using namespace std;
int n, N[200000 + 5], ans, num;
map<int, int> f;
set<int> pr;
vector<int> res;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &N[i]);
  for (int i = 1; i <= n; i++) {
    f[N[i]] = f[N[i] - 1] + 1;
    if (ans < f[N[i]]) {
      ans = f[N[i]];
      num = N[i];
    }
  }
  printf("%d\n", ans);
  for (int i = n; i >= 1; i--)
    if (N[i] == num) {
      res.push_back(i);
      num--;
    }
  reverse(res.begin(), res.end());
  for (int i = 0; i < res.size(); i++) printf("%d ", res[i]);
  return 0;
}
