class No878: def get_date(self): return list(map(int,input().split())) def count_highest(self,x): k, t = 0, 0 for i in range(len(x)): if x[i] > t: k += 1 t = x[i] print(k) def solve(self): n, q = self.get_date() a = self.get_date() for _ in range(q): query = self.get_date() l, r = query[1:] b = a[l - 1: r] self.count_highest(b) if __name__ == "__main__": pro = No878() pro.solve()