#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  map<long long, int> cnt;
  for (int i = 0; i < n; i++) cnt[a[i]] = cnt[a[i] - 1] + 1;
  int ans = 0, num;
  for (auto &it : cnt) {
    if (it.second > ans) {
      ans = it.second;
      num = it.first;
    }
  }
  vector<int> res;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == num) {
      res.push_back(i + 1);
      num--;
    }
  }
  cout << ans << '\n';
  for (int i = ans - 1; i >= 0; i--) cout << res[i] << ' ';
  return 0;
}
