#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> mas(n), dp(n, -1);
  for (int i = 0; i < n; i++) cin >> mas[i];
  int br = -1;
  for (int i = 0; i < n; i++) {
    if (mas[i] < 1) continue;
    if (mas[i] == 1) {
      dp[i] = i;
      if (br == -1) br = i;
      continue;
    }
    for (int j = i - 1; j >= 0; j--) {
      if (mas[j] + 1 == mas[i] && dp[j] != -1) {
        dp[i] = j;
        if (br == -1 || (br != -1 && mas[i] > mas[br])) br = i;
        break;
      }
    }
  }
  if (br == -1) {
    cout << 0 << endl;
    return 0;
  }
  cout << mas[br] << endl;
  int i = br;
  vector<int> ans;
  for (; dp[i] != i; i = dp[i]) {
    ans.push_back(2001 + i);
  }
  ans.push_back(2001 + i);
  for (i = ans.size() - 1; i >= 0; i--) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
