#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(1337);
ostream& operator<<(ostream& a, const pair<long long, long long> b) {
  cout << "{" << b.first << ", " << b.second << "}";
  return a;
}
ostream& operator<<(ostream& a, const vector<long long int>& b) {
  for (auto& k : b) cout << k << " ";
  return a;
}
ostream& operator<<(ostream& a, const vector<pair<long long, long long> >& b) {
  for (auto& k : b) cout << k << " ";
  return a;
}
const long long int INF = (long long int)1e18;
const long long int MOD = 1000 * 1000 * 1000 + 7, MOD2 = 274876858367;
const long long int maxn = (long long int)5e3 + 10, L = 22;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  map<long long int, long long int> dp;
  vector<long long int> a(n);
  long long int mx = 0, inx = 0;
  for (long long int i = 0; i < n; ++i) {
    cin >> a[i];
    long long int x = a[i];
    if (dp[x - 1] + 1 > dp[x] && dp[x - 1])
      dp[x] = dp[x - 1] + 1;
    else if (!dp[x])
      dp[x] = 1;
    if (dp[x] > mx) {
      mx = dp[x];
      inx = i;
    }
  }
  cout << mx << '\n';
  vector<long long int> res;
  long long int x = a[inx];
  for (long long int i = inx; i >= 0; --i) {
    if (a[i] == x) {
      --x;
      res.push_back(i);
    }
  }
  reverse(res.begin(), res.end());
  for (long long int x : res) cout << x + 1 << " ";
  return 0;
}
