public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		StringBuilder out = new StringBuilder();
		ArrayList<Integer> l = new ArrayList<Integer>(1100000);
		int n = 0;
		while ((line = in.readLine()) != null && line.length() != 0)
			l.add(Integer.parseInt(line.trim()));
		int[] a = new int[l.size()];
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
		int[] lis = findLIS(a);
		out.append(lis.length + "\n-\n");
		for (int i = 0; i < lis.length; i++)
			out.append(lis[i] + "\n");
		System.out.print(out);
	}