#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e18;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n);
  map<long long, long long> dp;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    dp[a[i]] = dp[a[i] - 1] + 1;
  }
  long long x, mx = -INF;
  for (auto &[last, len] : dp) {
    if (len > mx) {
      mx = len;
      x = last;
    }
  }
  cout << mx << '\n';
  long long l = x - mx + 1;
  for (long long i = 0; i < n; ++i) {
    if (a[i] == l) {
      cout << i + 1 << ' ';
      ++l;
    }
  }
}
