#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9, maxn = 2e5 + 98, N = 1e7 + 20, LOG = 20, mod = 1e9 + 7;
const int dx[] = {0, 0, -1, 1}, dy[] = {1, -1, 0, 0};
const long double eps = 1e-12, pi = 3.14159265359;
const pair<unsigned long long, unsigned long long> base = make_pair(127, 137);
const long long INF = 1e18;
map<int, int> dp;
int n, a[maxn];
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    dp[a[i]] = dp[a[i] - 1] + 1;
  }
  int res = a[1];
  for (int i = 2; i <= n; ++i)
    if (dp[res] < dp[a[i]]) res = a[i];
  vector<int> ans;
  for (int i = n; i > 0; --i)
    if (a[i] == res) {
      res--;
      ans.push_back(i);
    }
  reverse(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); ++i) cout << ans[i] << ' ';
  return 0;
}
