#include <cstdio>
#include <algorithm>
//#include <iostream>
using namespace std;
	
struct cut{
	int idx;
	long long time;
	long long height;
	
	cut(int i, long long t, long long h)
	: idx(i)
	, time(t)
	, height(h)
	{}
	
	cut()
	: idx(0)
	, time(0)
	, height(0)
	{}
};

bool revcmp(const int& a, const int& b){
	return b < a;
}

int speeds[500001];
long long sums[500001];
cut cuts[500001];
long long totalgrass;
int ntiers;

int last_cut_tier_idx(long long t, long long h){
	// TAK - ostatni -> kroimy wszystko
	// cokolwiek innego - trzeba szukać między ostatnim TAK i pierwszym NIE
	
	int p = 0;
	int k = ntiers;
	int n;
	while(true){
		n = (p + k) / 2;
		cut c = cuts[n];
		if((long long)speeds[c.idx] * (t - c.time) + c.height > h){
			// TRZEBA CIĄĆ
			if(n == 0){
				//tniemy wszystko
				return -1;
			}else{
				k = n - 1;
			}
		}else{
			// NIE TRZEBA CIĄĆ
			if(n == ntiers - 1){
				return n;
			}
			cut c2 = cuts[n + 1];
			if((long long)speeds[c2.idx] * (t - c2.time) + c2.height > h){
				// tutaj jest pierwsze NT
				return n;
			}else{
				p = n + 1;
			}
		}
	}
}


/*
 v-orig_p                        orig_k-v
TTTTTTTTTTTTTTTTTTTTTNNNNNNNNNNNNNNNNNNNN
^cuts[n + 1]                     cuts[n]^
*/

int last_cut_idx(long long t, long long h, int tier_idx){
	cut c = cuts[tier_idx];
	int orig_p; // orig_p - 1 JEST NA TAK
	int orig_k; // orig_k + 1 JEST NA NIE
	if(tier_idx == ntiers - 1){
		orig_p = 0;
	}else{
		cut c2 = cuts[tier_idx + 1];
		orig_p = c2.idx + 1;
	}
	int k = c.idx;
	int p = orig_p;
	int n;
	
	while(true){
		n = (p + k) / 2;
		if((long long)speeds[n] * (t - c.time) + c.height > h){
			// TAK
			p = n + 1;
		}else{
			// NIE
			if(n == orig_p || (long long)speeds[n - 1] * (t - c.time) + c.height > h){
				// n jest pierwszym NIE
				// n - 1 jest ostatnim TAK
				return n - 1;
			}
			k = n - 1;			
		}
	}
}


int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	
	for(int i = 0; i < n; ++i){
		scanf("%d", &speeds[i]);
	}
	sort(speeds, speeds + n, revcmp);
	
	sums[0] = speeds[0];
	for(int i = 1; i < n; ++i){
		sums[i] = sums[i - 1] + speeds[i];
	}
	cuts[0] = cut(n - 1, 0, 0);
	ntiers = 1;
	
	for(int i = 0; i < m; ++i){
		long long t;
		long long h;
		scanf("%lld %lld", &t, &h);
		int tier = last_cut_tier_idx(t, h);
		if(tier == -1){
			//cout << "TIER: -1" << endl;
			long long totalgrowth = sums[n - 1] * t;
			long long grass = totalgrowth - totalgrass - (long long)n * h;
			//cout << sums[n - 1] << " " << t << " ___ " << totalgrowth << " " << totalgrass << endl;
			printf("%lld\n", grass);
			totalgrass += grass;
			ntiers = 1;
			cuts[0] = cut(n - 1, t, h);
		}else{
			//cout << "TIER: " << cuts[tier].idx << ", X = ";
			int idx = last_cut_idx(t, h, tier);
			//cout << idx << endl;
			
			// idx - tniemy trawę od 0 do idx włącznie
			// idziemy po cuts od końca, całe przedziały obcinamy i przesuwamy koniec cutsa.
			// po obliczeniach wstawiamy (idx, t, h) do cuts.
			long long grass = 0;
			if(idx != -1){
				int orig_ntiers = ntiers - 1;
				for(int j = ntiers - 1; j >= 0; --j){
					long long hb = cuts[j].height;
					long long tb = cuts[j].time;
					//cout << idx << ": Trying " << cuts[j].idx << endl;
					int p, k;
					if(j == orig_ntiers){
						p = 0;
					}else{
						p = cuts[j + 1].idx + 1;
					}
					
					
					if(cuts[j].idx <= idx){
						//cout << "...Yup\n";
						k = cuts[j].idx;
						--ntiers;
					}else{
						//cout << "...Nope\n";
						k = idx;
						j = -1; // end loop
					}
					//cout << "p(" << p << "), k(" << k << ")\n";
					long long growth = sums[k] - sums[p] + speeds[p]; // works for p = 0, unlike sums[p - 1]
					grass += growth * (t - tb) - (long long)(k - p + 1) * (h - hb);
				}
				// wstawiamy nowe koszenie do tablycy
				cuts[ntiers] = cut(idx, t, h);
				++ntiers;
			}
				
			totalgrass += grass;
			printf("%lld\n", grass);
			//cout << "Total: " << totalgrass << endl;
				
		}
		
	
	}
	return 0;
}
