int[] answer = new int[commands.length+1];
int first =0;
int second =0;
int third =0;
for(int i=0; i<commands.length; i++){
first = commands[i][0];
second = commands[i][1];
third = commands[i][2];
int[] arr = Arrays.copyOfRange(array, first-1, second);
Arrays.sort(arr);
// for(int x : arr) System.out.println(x);
System.out.println(arr[third-1]);
answer[i] = arr[third-1];
}