#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), pr(n, -1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> dp(n, 1);
  map<int, pair<int, int>> mp;
  for (int i = 0; i < n; i++) {
    if (a[i] == -1) continue;
    int val = mp[a[i] - 1].first;
    int index = mp[a[i] - 1].second;
    if (val + 1 > dp[i]) {
      dp[i] = val + 1;
      pr[i] = index;
    }
    mp[a[i]] = {dp[i], i};
  }
  int maxsub = 0;
  int ind = 0;
  for (int i = 0; i < n; i++) {
    if (maxsub < dp[i]) {
      maxsub = dp[i];
      ind = i;
    }
  }
  cout << maxsub << "\n";
  vector<int> ans;
  while (ind != -1) {
    ans.push_back(ind);
    ind = pr[ind];
  }
  for (int i = ans.size() - 1; i >= 0; i--) {
    cout << ans[i] + 1 << " ";
  }
}
int main() {
  solve();
  return 0;
}
