#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 5;
map<int, int> dp;
int a[N];
int n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) dp[a[i]] = max(dp[a[i]], dp[a[i] - 1] + 1);
  int ans = 0, t = -1;
  for (int i = 0; i < n; i++)
    if (ans < dp[a[i]]) {
      ans = dp[a[i]];
      t = i;
    }
  int k = a[t] - ans + 1;
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    if (a[i] == k) {
      cout << i + 1 << " ";
      k++;
    }
  }
}
