#include <bits/stdc++.h>
using namespace std;
const int INF = 1e+9;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int m = 0;
  int last = 0;
  int li = 0;
  int x;
  unordered_map<int, int> d;
  d.reserve(4096);
  d.max_load_factor(0.25);
  for (int i = 0; i < n; ++i) {
    x = a[i];
    d[x] = d[x - 1] + 1;
    if (d[x] > m) {
      m = d[x];
      last = x;
      li = i;
    }
  }
  printf("%d\n", m);
  int k = last;
  deque<int> res;
  for (int i = li; i >= 0 && k > last - m; --i) {
    if (a[i] == k) {
      res.push_front(i + 1);
      --k;
    }
  }
  for (int e : res) {
    printf("%d ", e);
  }
  return 0;
}
