#include <bits/stdc++.h>
using namespace std;
map<string, int> check, mlen, sloc;
int main() {
  int n, mx = 0, sti = 0, go = 0, val;
  scanf("%d", &n);
  int ar[n + 1];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ar[i]);
  }
  for (int i = 1; i <= n; i++) {
    string str = to_string(ar[i] - 1), str2;
    str2 = str;
    if (check[str] == 1) {
      str = to_string(ar[i]);
      check[str] = 1;
      mlen[str] = mlen[str2] + 1;
      sloc[str] = sloc[str2];
      if (mx < mlen[str]) {
        mx = mlen[str];
        sti = sloc[str];
        go = i;
      }
    } else {
      str = to_string(ar[i]);
      check[str] = 1;
      mlen[str] = 1;
      sloc[str] = i;
      if (mx < 1) {
        mx = 1;
        sti = i;
        go = i;
      }
    }
  }
  printf("%d\n", mx);
  val = ar[sti];
  for (int i = sti; i <= go; i++) {
    if (val == ar[i]) {
      printf("%d ", i);
      val++;
    }
  }
  return 0;
}
