#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  scanf("%d", &N);
  vector<int> a(N);
  map<int, int> mmap;
  map<int, int> imap;
  vector<int> prev(N);
  int ret = -1, reti = -1;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
    if (mmap.count(a[i] - 1) == 1) {
      mmap[a[i]] = mmap[a[i] - 1] + 1;
      imap[a[i]] = i;
      prev[i] = imap[a[i] - 1];
    } else {
      mmap[a[i]] = 1;
      imap[a[i]] = i;
      prev[i] = -1;
    }
    if (ret < mmap[a[i]]) {
      ret = mmap[a[i]];
      reti = i;
    }
  }
  printf("%d\n", ret);
  vector<int> v;
  while (reti != -1) {
    v.push_back(reti);
    reti = prev[reti];
  }
  for (int i = v.size() - 1; i >= 0; --i) printf("%d ", v[i] + 1);
  printf("\n");
}
