SP9055 FREQ2 - Most Frequent Value

Description

You are given a sequence of **n** integers **a $ _{0} $ , a $ _{1} $ , ..., a $ _{n-1} $** . You are also given several queries consisting of indices **i** and **j** (_0 ). For each query, determine the number of occurrences of the most frequent value among the integers **a $ _{i} $ , ..., a $ _{j} $** ._

Input Format

First line contains two integers **n** and **q** (_1 ). The next line contains **n** integers **a $ _{0} $ , ... ,a $ _{n-1} $** (_0 , for each _i ∈ {0, ..., n-1}_) separated by spaces. The following **q** lines contain one query each, consisting of two integers **i** and **j** (_0 ), which indicates the boundary indices for the query.___

Output Format

For each query, print one line with one integer: The number of occurrences of the most frequent value within the given range.