#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
int a[N];
map<int, int> mp;
int main() {
  int n, maxx = -1, maxxx;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]] = mp[a[i] - 1] + 1;
    if (maxx < mp[a[i]]) {
      maxx = mp[a[i]];
      maxxx = a[i];
    }
  }
  int l = maxxx - maxx + 1;
  cout << maxx << '\n';
  for (int i = 0; i < n; i++) {
    if (a[i] == l) {
      cout << i + 1 << " ";
      l++;
    }
  }
  return 0;
}
