public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int length = in.nextInt();
		int testCases = in.nextInt();
		
		int[] laneWidth = new int[length];
		
		for (int i = 0; i < length; i++) {
			laneWidth[i] = in.nextInt();
		}
		
		while (testCases > 0) {
			System.out.println(serLane(laneWidth, in.nextInt(), in.nextInt()));
			testCases--;
		}
	}