import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int q = sc.nextInt(); PriorityQueue queue = new PriorityQueue<>(); for (int i = 0; i < n; i++) { queue.add(new Unit(sc.nextInt(), i)); } TreeSet idxes = new TreeSet<>(); idxes.add(n); int[][] nexts = new int[17][n + 1]; while (queue.size() > 0) { Unit u = queue.poll(); nexts[0][u.idx] = idxes.higher(u.idx); idxes.add(u.idx); } nexts[0][n] = n; for (int i = 1; i < 17; i++) { for (int j = 0; j <= n; j++) { nexts[i][j] = nexts[i - 1][nexts[i - 1][j]]; } } StringBuilder sb = new StringBuilder(); while (q-- > 0) { sc.nextInt(); int left = sc.nextInt() - 1; int right = sc.nextInt() - 1; int ans = 1; for (int i = 16; i >= 0; i--) { if (nexts[i][left] <= right) { left = nexts[i][left]; ans += (1 << i); } } sb.append(ans).append("\n"); } System.out.print(sb); } static class Unit implements Comparable { int value; int idx; public Unit(int value, int idx) { this.value = value; this.idx = idx; } public int compareTo(Unit another) { return another.value - value; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }