#include <bits/stdc++.h>
using namespace std;
int64_t maxm(int64_t a, int64_t b) { return a > b ? a : b; }
int64_t minm(int64_t a, int64_t b) { return a > b ? b : a; }
int main() {
  ios_base::sync_with_stdio(false);
  int64_t n, i;
  cin >> n;
  int64_t a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  map<int64_t, int64_t> m;
  for (auto &x : a) m[x] = maxm(m[x], m[x - 1] + 1);
  int64_t mx = 0, l = 0;
  for (auto i = m.begin(); i != m.end(); i++) {
    if (mx < (i->second)) {
      mx = i->second;
      l = i->first;
    }
  }
  vector<int64_t> v;
  for (i = n - 1; i >= 0; i--) {
    if (a[i] == l) {
      v.push_back(i + 1);
      l--;
    }
  }
  sort(v.begin(), v.end());
  cout << mx << endl;
  for (i = 0; i < v.size(); i++) cout << v[i] << " ";
}
