static int[] check_answer(int[] A, int[] E) {
	  boolean[] exist = new boolean[A.length];
	  int[] ans = new int[E.length];

	  for (int i = 0; i < E.length; ++i) {
	    int min_val = Integer.MAX_VALUE;
	    for (int j = 0; j <= E[i]; ++j) {
	      if (A[j] < min_val && !exist[A[j]]) {
	        min_val = min(A[j], min_val);
	      }
	    }
	    exist[min_val] = true;
	    ans[i] = min_val;
	  }
	  /*
	    System.out.print("ans2 = ");
	    System.out.println(Arrays.toString(ans));
	    */
	  return ans;
	}