#include <bits/stdc++.h>
using namespace std;
int const N = 2 * 1e5 + 10;
map<long long, int> m;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    if (!m.count(a[i] - 1)) {
      m[a[i]] = 1;
    } else {
      m[a[i]] = max(m[a[i]], m[a[i] - 1] + 1);
    }
  }
  int mx = 0, val;
  for (auto e : m) {
    if (e.second > mx) {
      mx = e.second;
      val = e.first;
    }
  }
  vector<int> res;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == val) res.push_back(i), val--;
  }
  cout << res.size() << endl;
  for (int i = res.size() - 1; i >= 0; i--) cout << res[i] + 1 << " ";
}
