#include <bits/stdc++.h>
using namespace std;
int a[200005];
int main() {
  map<int, int> m;
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    m[a[i]] = m[a[i] - 1] + 1;
  }
  int ans = 0;
  int anss;
  map<int, int>::iterator it;
  for (it = m.begin(); it != m.end(); it++) {
    if (it->second > ans) {
      ans = it->second;
      anss = it->first;
    }
  }
  int ansb = anss - ans + 1;
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++) {
    if (a[i] == ansb) {
      printf("%d ", i);
      ansb++;
    }
    if (ansb > anss) {
      break;
    }
  }
  return 0;
}
