#include <bits/stdc++.h>
using namespace std;
long long query(const vector<int> &values) {
long long answer = 0;
int N = values.size();
vector<int> left(N+2), right(N+2);
for (int n=0; n<N+2; ++n) { left[n] = n+1; right[n] = n-1; }
vector< pair<int,int> > events;
for (int n=0; n<N; ++n) events.push_back( { values[n], n+1 } );
sort( events.begin(), events.end() );
for (const auto &ev : events) {
int le = left[ev.second-1], re = right[ev.second+1];
answer += 1LL * ev.first * (ev.second - le + 1) * (re - ev.second + 1);
right[le] = re; left[re] = le;
}
return answer;
}
int main() {
int N, Q;
cin >> N >> Q;
vector<int> A(N);
for (int &a : A) cin >> a;
vector<int> D(N-1);
for (int n=0; n<N-1; ++n) D[n] = abs( A[n+1]-A[n] );
while (Q--) {
int l, r; cin >> l >> r;
cout << query( vector<int>( D.begin()+l-1, D.begin()+r-1 ) ) << endl;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpsb25nIGxvbmcgcXVlcnkoY29uc3QgdmVjdG9yPGludD4gJnZhbHVlcykgewogICAgbG9uZyBsb25nIGFuc3dlciA9IDA7CiAgICBpbnQgTiA9IHZhbHVlcy5zaXplKCk7CiAgICAKICAgIHZlY3RvcjxpbnQ+IGxlZnQoTisyKSwgcmlnaHQoTisyKTsKICAgIGZvciAoaW50IG49MDsgbjxOKzI7ICsrbikgeyBsZWZ0W25dID0gbisxOyByaWdodFtuXSA9IG4tMTsgfQogICAgCiAgICB2ZWN0b3I8IHBhaXI8aW50LGludD4gPiBldmVudHM7CiAgICBmb3IgKGludCBuPTA7IG48TjsgKytuKSBldmVudHMucHVzaF9iYWNrKCB7IHZhbHVlc1tuXSwgbisxIH0gKTsKICAgIHNvcnQoIGV2ZW50cy5iZWdpbigpLCBldmVudHMuZW5kKCkgKTsKICAgIAogICAgZm9yIChjb25zdCBhdXRvICZldiA6IGV2ZW50cykgewogICAgICAgIGludCBsZSA9IGxlZnRbZXYuc2Vjb25kLTFdLCByZSA9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