#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 3e6 + 5;
const long long MOD = 1e9 + 9;
const long double eps = 1e-6;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  map<int, int> dp;
  int n;
  cin >> n;
  vector<int> a(n);
  int ans = 0;
  int pos = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    dp[a[i]] = dp[a[i] - 1] + 1;
    if (ans < dp[a[i]]) {
      ans = dp[a[i]];
      pos = i;
    }
  }
  vector<int> v;
  int x = ans - 1;
  int cur_pos = pos - 1;
  v.push_back(pos);
  while (cur_pos >= 0) {
    if (a[cur_pos] == a[v.back()] - 1) {
      v.push_back(cur_pos);
    }
    cur_pos--;
  }
  cout << ans << "\n";
  reverse(v.begin(), v.end());
  for (int i = 0; i < v.size(); ++i) {
    cout << v[i] + 1 << " ";
  }
  return 0;
}
