#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n = 0;
  cin >> n;
  map<int, int> dp;
  vector<int> a(n);
  int maxans = 0, maxa;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dp[a[i]] = max(dp[a[i] - 1] + 1, dp[a[i]]);
    if (dp[a[i]] > maxans) {
      maxans = dp[a[i]];
      maxa = a[i];
    }
  }
  cout << maxans << endl;
  vector<int> ans;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == maxa) {
      ans.push_back(i + 1);
      maxa--;
    }
  }
  for (auto i = ans.rbegin(); i != ans.rend(); i++) cout << *i << " ";
  cout << endl;
}
