#include <bits/stdc++.h>
using namespace std;
const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};
const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, 1, 0, -1, -1, 1, -1, 1};
const long double pie = 3.1415926535897932384626;
const long long N = 300009;
int main() {
  long long n;
  cin >> n;
  map<long long, long long> umap;
  long long arr[n];
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    arr[i] = x;
    umap[x] = max(umap[x], umap[x - 1] + 1);
  }
  long long maxi = 0, p;
  for (long long i = 0; i < n; i++) {
    if (umap[arr[i]] > maxi) {
      maxi = umap[arr[i]];
      p = i;
    }
  }
  cout << maxi << "\n";
  long long itr = arr[p];
  vector<long long> brr;
  for (long long i = n - 1; i >= 0; i--) {
    if (arr[i] == itr) {
      brr.push_back(i + 1);
      itr--;
    }
  }
  for (long long i = brr.size() - 1; i >= 0; i--) {
    cout << brr[i] << " ";
  }
  return 0;
}
