#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 9;
const int MAX = 6e5 + 9;
const int MAX1 = 5e6 + 9;
const int INF = 0x3f3f3f3f;
const long double ep = 1e-12;
const double ep1 = 1e-14;
const int mod = 998244353;
const double inf = 1e20;
const long double pi = acos(-1);
map<int, int> mp;
int n, a[maxn], cnt, las;
void solve() {
  scanf("%d", &(n));
  for (int i = (1); i <= (n); ++i) {
    scanf("%d", &(a[i]));
    int tot = mp[a[i]] = mp[a[i] - 1] + 1;
    if (cnt < tot) cnt = tot, las = a[i];
  }
  printf("%d\n", (cnt));
  las = las - cnt + 1;
  for (int i = (1); i <= (n); ++i) {
    if (a[i] == las) printf("%d ", (i)), las++;
  }
  puts("");
}
int main() {
  int T = 1;
  while (T--) solve();
}
