#include <bits/stdc++.h>
using namespace std;
long long i, j, k, n, a[200009], b[200009], ans, val, sz;
map<long long, long long> mp;
vector<long long> v;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%I64d", &a[i]);
    mp[a[i]] = mp[a[i] - 1] + 1;
    if (mp[a[i]] > ans) {
      ans = mp[a[i]];
      val = a[i];
    }
  }
  for (i = n - 1; i >= 0; i--) {
    if (a[i] == val) {
      val--;
      v.push_back(i + 1);
    }
  }
  sz = v.size();
  cout << sz << endl;
  for (i = sz - 1; i >= 0; i--) cout << v[i] << " ";
  return 0;
}
