#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  map<int, vector<int>> mp;
  for (int i = 1; i <= n; ++i) mp[a[i - 1]].push_back(i);
  vector<int> dp(n + 1, 1), id(n + 1, -1);
  for (int i = 1; i <= n; ++i) {
    auto it = lower_bound(mp[a[i - 1] + 1].begin(), mp[a[i - 1] + 1].end(), i);
    if (it != mp[a[i - 1] + 1].end()) {
      if (dp[i] + 1 > dp[*it]) {
        dp[*it] = dp[i] + 1;
        id[*it] = i;
      }
    }
  }
  int k = 0, best = 0;
  for (int i = 1; i <= n; ++i)
    if (dp[i] > best) best = dp[i], k = i;
  cout << dp[k] << "\n";
  stack<int> s;
  s.push(k);
  while (id[k] != -1) {
    k = id[k];
    s.push(k);
  }
  while (!s.empty()) cout << s.top() << " \n"[s.size() == 1], s.pop();
  return 0;
}
