import java.util.*;
class Solution {
public int[] solution(int[] array, int[][] commands) {
int[] answer = new int[commands.length];
for(int i = 0; i < commands.length; i++) {
int a = commands[i][0];
int b = commands[i][1];
int c = commands[i][2];
Integer[] dummyA = new Integer[b - a + 1];
int k = 0;
for(int j = a -1; j < b; j++) {
dummyA[k] = array[j];
k++;
}
Arrays.sort(dummyA);
answer[i] = dummyA[c-1];
}
return answer;
}
}