#include <iostream>
using namespace std;

int main()
{
    int n, q;
    
    cin >> n;
    cin >> q;
    
    int l, r;
    int maks, k;
    
    int a[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    int ol[q];
    
    for(int i = 0; i < q; i++){
        cin >> l;
        cin >> r;
        maks = 1;
        
        for (int j = l - 1; j < r - 1; j++){
            k = 0;
            for (int m = l - 1; m < r - 2; m++){
                if (a[j] && a[j+1] < a[j] ^ a[j+1]){
                    k += 1;
                }
            }
            if (k > maks){
                maks = k;
            }
        }
        ol[i] = maks;
        
    }
    
    for(int i = 0; i < q; i++){
        cout << ol[i] << endl;
    }
    
    return 0;
}