#include <iostream>
#include <fstream>
using namespace std;
//#define N 25001;
ifstream f("cuburi2.in");
ofstream g("cuburi2.out");
long a[5000][5000],b[5000];
long n, m, i, j, nr=0, x, y, min1 = 1000001;
int main()
{
f>>n>>m;
for (i=1;i<=n;i++)
f>>b[i];
for (i=1;i<=n;i++)
for (j=i+1;j<=n;j++)
a[i][j] = a[i][j-1] + (j-i) * b[j];
for (i=1;i<=n;i++)
for (j=i-1;j>=1;j--)
a[i][j] = a[i][j+1] + (i-j) * b[j];
int l, poz;
for (l=1;l<=m;l++) {
f>>x>>y;
min1=a[x][y];
poz=x;
for (j=x+1;j<=y;j++)
if (min1 > a[j][x]+a[j][y]) {
min1 = a[j][x] + a[j][y];
poz=j;
}
g<<poz<<"\t"<<min1<<endl;
}
/*Calculare TIMP POZITIE: INTERVAL 1-5, TURN 3:
1 3 7 2 5
2*1 + 1*3 + 1*2 + 5*2 = 17
FORMULA: (i-j) * b[j]
*/
return 0;
}