import java.io.*;
import java.util.*;

public class race_vd {
	BufferedReader in;
	StringTokenizer str;
	PrintWriter out;
	String SK;

	String next() throws IOException {
		while ((str == null) || (!str.hasMoreTokens())) {
			SK = in.readLine();
			if (SK == null)
				return null;
			str = new StringTokenizer(SK);
		}
		return str.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	void solve() throws IOException {
		int n = nextInt();
		ArrayList<Integer> res = new ArrayList<Integer>();
		int max = 0;
		for (int i = 1; i <= n; i++) {
			max = Math.max(max, nextInt());
			if (max == i) {
				res.add(i);
			}
		}
		out.println(res.size());
		for (int i : res) {
			if (i == n) {
				out.println(i);
			} else {
				out.print(i + " ");
			}
		}

	}

	void run() throws IOException {
		in = new BufferedReader(new FileReader("race.in"));
		out = new PrintWriter("race.out");
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new race_vd().run();
	}

}