#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  ;
  m.clear();
  vector<int> v(n);
  for (int i = 0; i < (int)v.size(); i++) {
    cin >> v[i];
  };
  int cur = 0;
  int ans = 0, ind = -1;
  for (int i = 0; i < n; i++) {
    if (m.count(v[i] - 1)) {
      cur = m[v[i] - 1];
      m[v[i]] = (cur + 1);
      if (ans < m[v[i]]) {
        ans = m[v[i]];
        ind = i;
      }
    } else {
      m[v[i]] = 1;
    }
  }
  ans = max(1, ans);
  if (ind == -1) {
    ind = 0;
  }
  cur = v[ind] + 1;
  cout << ans << endl;
  vector<int> seq;
  for (int i = ind; i >= 0; i--) {
    if (v[i] == cur - 1) {
      seq.push_back(i + 1);
      cur--;
    }
  }
  reverse(seq.begin(), seq.end());
  for (int i = 0; i < (int)seq.size(); i++) {
    cout << seq[i] << " ";
  };
  cout << endl;
  return 0;
}
