import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } sc.close(); Set set = new HashSet<>(); int r = n - 1; for (int i = 0; i < n; i++) { if (!set.add(a[i])) { r = i; break; } } set.clear(); int l = 0; for (int i = n - 1; i >= 0; i--) { if (!set.add(a[i])) { l = i; break; } } int ans = Math.max(r - l, 0); System.out.println(ans); if (ans == 0) { System.out.println(); } else { StringBuilder sb = new StringBuilder(); for (int i = l; i < r; i++) { sb.append(i + 1).append(' '); } sb.deleteCharAt(sb.length() - 1); System.out.println(sb.toString()); } } }