#include <bits/stdc++.h>
using namespace std;
int n;
map<int, bool> mp;
map<int, int> lastPos;
vector<int> v, cumSum, result;
int main() {
  cin >> n;
  v.resize(n), cumSum.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    cumSum[i] = 1;
  }
  for (int i = 0; i < n; i++) {
    if (mp[v[i] - 1]) {
      cumSum[i] += cumSum[lastPos[v[i] - 1]];
    }
    mp[v[i]] = 1;
    lastPos[v[i]] = i;
  }
  int mx = 0, pos;
  for (int i = n - 1; i >= 0; i--) {
    if (mx < cumSum[i]) {
      pos = i;
      mx = cumSum[i];
    }
  }
  cout << mx << endl;
  int q = v[pos];
  for (int i = pos; i >= 0; i--) {
    if (v[i] == q) {
      result.push_back(i + 1);
      q--;
    }
  }
  for (int i = result.size() - 1; i >= 0; i--) cout << result[i] << " ";
  return 0;
}
