#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int maxipos = -1, maxival;
  map<int, int> dp;
  for (int i = 0; i < n; i++) {
    dp[a[i]] = dp[a[i] - 1] + 1;
    if (dp[a[i]] > maxipos) {
      maxipos = dp[a[i]];
      maxival = a[i];
    }
  }
  vector<int> positions;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == maxival) {
      positions.push_back(i + 1);
      maxival--;
    }
  }
  sort(positions.begin(), positions.end());
  cout << maxipos << endl;
  for (int i = 0; i < positions.size(); i++) {
    printf("%d ", positions[i]);
  }
  return 0;
}
