--------------------------------------------------------------------------
数组也有sort方法
尽量把输入和操作分开写
--------------------------------------------------------------------------
import java.util.*;
public class Main {
public static void main(String[] args) {
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();
int m = sc.nextInt();
int[] l = new int[m];
int[] r = new int[m];
int[] K = new int[m];
for(int i=0;i<m;i++) {
l[i] = sc.nextInt();
r[i] = sc.nextInt();
K[i] = sc.nextInt();
}
int[] res = new int[m];
for(int i=0;i<m;i++) {
int[] b = new int[r[i]-l[i]+1];
int w = l[i] - 1;
for(int j=0,k=w;j<b.length;j++,k++)
b[j] = a[k];
Arrays.sort(b);
res[i] = b[b.length-K[i]];
}
for(int i:res)
System.out.println(i);
}
}