You are given a sequence of n integers a1 , a2 , … , an in non-decreasing order. In addition to that, you are given several queries consisting of indices i and j (1 ≤ i ≤ j ≤ n). For each query, determine the most frequent value among the integers ai , … , aj.

1 ≤ n, q ≤ 100000) and (-100000 ≤ ai ≤ 100000) !!

I’m trying to solve it using a segment tree but unable to find what to store in the node?