#include <bits/stdc++.h>
using namespace std;
const int N = 720720;
const int MOD = 1e9 + 7;
void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  map<int, int> dp;
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    dp[v[i]] = 0;
  }
  int mx = 0;
  int ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    dp[v[i]] = dp[v[i] + 1] + 1;
    if (mx < dp[v[i]]) {
      mx = dp[v[i]];
      ans = v[i];
    }
  }
  cout << mx << endl;
  for (int i = 0; i < n; ++i) {
    if (v[i] == ans) {
      cout << i + 1 << " ";
      ans++;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
