#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
const int MAXN = 250005;
long long S[MAXN];
long long SP[MAXN];
int main() {
ifstream cin("cuburi2.in");
ofstream cout("cuburi2.out");
int n, m;
if (!(cin >> n >> m)) return 0;
S[0] = 0;
SP[0] = 0;
for (int i = 1; i <= n; ++i) {
long long h;
cin >> h;
S[i] = S[i - 1] + h;
SP[i] = SP[i - 1] + h * i;
}
for (int q = 0; q < m; ++q) {
int x, y;
cin >> x >> y;
long long total_cuburi = S[y] - S[x - 1];
if (total_cuburi == 0) {
cout << x << " 0\n";
continue;
}
long long target = S[x - 1] + (total_cuburi + 1) / 2;
int P = lower_bound(S + x, S + y + 1, target) - S;
long long cost_stanga = 1LL * P * (S[P - 1] - S[x - 1]) - (SP[P - 1] - SP[x - 1]);
long long cost_dreapta = (SP[y] - SP[P]) - 1LL * P * (S[y] - S[P]);
cout << P << " " << (cost_stanga + cost_dreapta) << "\n";
}
return 0;
}