#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cassert>

using namespace std;

static const int inf = 1000000010;

vector<int> right_min;
vector<int> left_max;
vector<int> a;
vector<bool> ans;

int main()
{
	ifstream in("cubes.in");
	ofstream out("cubes.out");
	
	int n;
	in >> n;
	assert(n > 0 && n <= 300000);
	
	int tmp;
	a.push_back(-1);
	
	
	for (int i = 0; i < n; i++)
	{
		in >> tmp;
		assert(tmp > 0 && tmp <= 1000000000);
		a.push_back(tmp);
	}
	
	right_min.resize(n + 2);
	left_max.resize(n + 2);
	
	right_min[n + 1] = inf;
	left_max[0] = -1;
	for (int i = 1; i <= n; i++)
	{
		right_min[n - i + 1] = min(a[n - i + 1], right_min[n - i + 2]);
		left_max[i] = max(a[i], left_max[i - 1]);
	}
	
	int result = 0;
	ans = vector<bool>(n + 1, false);
	for (int i = 1; i < n; i++)
	{
		if (right_min[i + 1] > left_max[i])
		{
			result++;
			ans[i] = true;
		}
	}
	
	out << result << '\n';
	for (int i = 1; i <= n - 1; i++)
	{
		if (ans[i])
			out << i << " " ;
	}
	
	return 0;
}
