#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 5;
int a[N];
map<int, int> mmi;
int main() {
  int n, Maxx = 0, vvi, ans;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    mmi[a[i]] = mmi[a[i] - 1] + 1;
    if (mmi[a[i]] > Maxx) {
      vvi = a[i];
      Maxx = mmi[a[i]];
      for (int i = 0; i < 5; i++)
        ;
    }
  }
  vvi = vvi - Maxx + 1;
  cout << Maxx << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 5; j++)
      ;
    if (a[i] == vvi) {
      cout << i + 1 << " ";
      ans++;
      vvi++;
    }
    if (ans == Maxx) return 0;
  }
  return 0;
}
