#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
struct trip{
LL day;
LL element;
LL high;
void make_trip(LL a, LL b, LL c){
day = a;
element = b;
high = c;
}
};
#define el element
#define PLL pair<LL, LL>
#define st first
#define nd second
#define mp make_pair
#define PII pair<int, int>
#define mt make_trip
const int mxn = 500007;
const LL INF = 1000000000005LL;
LL t[mxn];
LL suf[mxn];
LL add(LL from, LL to, LL sh, LL eh, LL sd, LL ed){
if(to < from)
return 0LL;
return ((to-from+1)*(sh-eh))+((suf[from] - suf[to+1])*(ed-sd));
}
LL BS(LL from, LL to, LL sh, LL eh, LL sd, LL ed){
while(from < to){
LL sred = (from + to)/2LL;
if(sh + (ed - sd)*t[sred] <= eh)
from = sred+1;
else
to = sred;
}
return from;
}
int main() {
LL n, m;
scanf("%lld %lld", &n, &m);
for(int i=1; i<=n; ++i)
scanf("%lld", &t[i]);
t[n+1] = INF;
sort(t+1, t+n+1);
for(int i=n; i>=0; --i)
suf[i] = suf[i+1] + t[i];
deque <trip> Q;
trip X;
X.mt(0LL, 0LL, 0LL);
Q.push_back(X);
while(m--){
LL day, high;
scanf("%lld %lld", &day, &high);
trip k = Q.back();
trip last;
last.mt(day, n+1, high);
LL result = 0LL;
while((day - k.day)*t[k.el] + k.high > high){
Q.pop_back();
result+= add(k.el, last.el-1, k.high, high, k.day, day);
last = k;
k=Q.back();
}
LL where = BS(k.el, last.el, k.high, high, k.day, day);
result+= add(where, last.el-1, k.high, high, k.day, day);
printf("%lld\n", result);
X.mt(day, where, high);
Q.push_back(X);
}
return 0;
}