#include <bits/stdc++.h>
int a[2000002], b[2000002], c[2000002];
int main() {
  int n;
  std::cin >> n;
  for (int i = 1; i <= n; i++) {
    std::cin >> a[i];
    b[i] = a[i];
  }
  std::sort(b + 1, b + 1 + n);
  int t = 0;
  for (int i = 1; i <= n; i++)
    if (b[i] != b[i - 1]) b[++t] = b[i];
  b[0] = -1;
  for (int i = 1; i <= n; i++) {
    int k = (int)(std::lower_bound(b + 1, b + 1 + t, a[i]) - b);
    if (b[k - 1] + 1 == b[k]) {
      c[k] = c[k - 1] + 1;
    } else
      c[k] = 1;
  }
  int g = 0, gg = 0;
  for (int i = 1; i <= n; i++) {
    if (c[i] > g) g = c[i], gg = i;
  }
  std::cout << g << std::endl;
  bool p = 0;
  gg = gg - g + 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] == b[gg] && g) {
      g--;
      gg++;
      if (p) std::cout << ' ';
      p = 1;
      std::cout << i;
    }
  }
  std::cout << std::endl;
}
