using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int q = int.Parse(s[1]);
            string[] s2 = Console.ReadLine().Split();
            int[] a = new int[n];
            int[] b = new int[n];
            double d = Math.Pow(2, 16);
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(s2[i]);
                int br = 0;
                 
                while (a[i] != 0)
                {
                    if ((double)(a[i]) < d)
                        a[i] >>= 1;
                    else
                        a[i] <<= 1;
                    br++;
                }
                b[i] = br;
            }

            int[] izlaz = new int[q];
            for (int i = 0; i < q; i++)
            {
                int[] res = new int[32];
                string[] k = Console.ReadLine().Split();
                int l = int.Parse(k[0]) - 1;
                int r = int.Parse(k[1]) - 1;
                for (int j = l; j <= r; j++)
                {
                    res[b[j]]++;
                }
                izlaz[i] = res.Max();
            }
            for (int i = 0; i < q; i++)
            {
                Console.WriteLine(izlaz[i]);
            }
        }
    }
}