#include <bits/stdc++.h>
using namespace std;
long long a[200005], ind, mx, n, k, i, ans[2000005], bef;
map<long long, int> dp;
int main() {
  cin >> n;
  for (k = 1; k <= n; k++) {
    cin >> a[k];
  }
  for (k = 1; k <= n; k++) {
    dp[a[k]] = dp[a[k] - 1] + 1;
    if (dp[a[k]] > mx) {
      mx = dp[a[k]];
      ind = k;
    }
  }
  for (k = ind; k >= 1; k--) {
    i++;
    ans[i] = k;
    bef = k;
    while (a[k] != a[bef] - 1 && k >= 1) k--;
    k++;
  }
  cout << mx << endl;
  sort(ans + 1, ans + i + 1);
  for (k = 1; k <= i; k++) cout << ans[k] << " ";
}
