#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, vector<int>> indices;
  for (int i = 0; i < n; i++) cin >> a[i], indices[a[i]].push_back(i);
  map<int, int> dp;
  int mxn = 0, ans = -1;
  for (int i = n - 1; i >= 0; i--) {
    dp[a[i]] = 1 + dp[a[i] + 1];
    if (dp[a[i]] > mxn) mxn = dp[a[i]], ans = a[i];
  }
  cout << mxn << "\n";
  int prevI = -1, currA = ans;
  while (mxn) {
    int currI =
        lower_bound(indices[currA].begin(), indices[currA].end(), prevI) -
        indices[currA].begin();
    cout << indices[currA][currI] + 1 << " ";
    prevI = indices[currA][currI], currA++, mxn--;
  }
  return 0;
}
