class No878: def get_date(self): return list(map(int,input().split())) def count_highest(self,x): k = 1 for i in range(1,len(x)): if x[i] > max(x[:i]): k += 1 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()