#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
int a[200020];
int b[200020];
int main() {
  int n, i, id, maxn;
  while (cin >> n) {
    m.clear();
    id = 0;
    maxn = 0;
    for (i = 0; i < n; i++) {
      cin >> a[i];
      m[a[i]] = m[a[i] - 1] + 1;
      if (m[a[i]] > maxn) {
        maxn = m[a[i]];
        id = i;
      }
    }
    cout << maxn << endl;
    int k = 1;
    b[k++] = id + 1;
    for (i = id - 1; i >= 0; i--) {
      if (maxn == k - 1) break;
      if (a[i] == a[id] - 1) {
        b[k++] = i + 1;
        id = i;
      }
    }
    for (i = k - 1; i > 1; i--) {
      cout << b[i] << " ";
    }
    cout << b[1] << endl;
  }
  return 0;
}
