#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int inf = 0x7fffffff;
const int mod = 1e9 + 7;
const int eps = 1e-6;
long long a[N];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  map<long long, long long> ma;
  long long maxx = -1, x = -1;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (ma[a[i] - 1] + 1 > ma[a[i]]) {
      ma[a[i]] = ma[a[i] - 1] + 1;
    }
    if (maxx < ma[a[i]]) {
      maxx = ma[a[i]];
      x = a[i];
    }
  }
  cout << maxx << '\n';
  long long f = x - maxx + 1;
  for (long long i = 1; i <= n; i++) {
    if (a[i] == f) {
      cout << i << ' ';
      f++;
    }
  }
}
