#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> line(n);
  for (int& i : line) cin >> i;
  map<int, int> dp, last_pos;
  vector<int> prev(n, -1);
  for (int j = 0; j < n; j++) {
    int i = line[j];
    if (!dp.count(i - 1)) {
      dp[i] = 1;
    } else {
      dp[i] = dp[i - 1] + 1;
      prev[j] = last_pos[i - 1];
    }
    last_pos[i] = j;
  }
  int ans = 0;
  for (auto [i, j] : dp)
    if (dp[ans] < j) ans = i;
  cout << dp[ans] << endl;
  int pos = last_pos[ans];
  vector<int> ansy = {pos};
  while (prev[pos] != -1) {
    ansy.push_back(prev[pos]);
    pos = prev[pos];
  }
  for (int i = (int)ansy.size() - 1; i > -1; i--) cout << ansy[i] + 1 << " ";
  cout << endl;
}
signed main() {
  int q = 1;
  while (q--) solve();
  return 0;
}
