/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   																												   
list<int>::iterator it;																								   
list<int>::iterator it1;																							   
vector<int>::iterator it2;																							   
vector<int>::iterator it3;																							   
set<int>::iterator it4;																								   
map<string, int>::iterator it5; 																					   
vector<ii>::iterator iter;																						   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

LL tab[10000005];
vector< pair<LL, LL> >x;
///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////




/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++){
		cin >> tab[i];
	}
	for(int i = 0; i < m; i++){
		LL a, b;
		cin >> a >> b;
		x.pb(mp(b, a));
	}
	
	sort(tab, tab + n);
	
	//cout << "tab: " << endl;
	//for(int i = 0; i < n; i++){
		//cout << tab[i] << " ";
	//} 
	//cout << endl;
	
	//cout << "vector x: " << endl;
	sort(x.begin(), x.end());
	reverse(x.begin(), x.end());
	//for(auto it : x){
		//cout << it.first << " " << it.second << endl;
	//}
	
	int i = 0;
	for(auto ite : x){
		int temp = ite.second;
		while(tab[i] < ite.first && temp > 0 && i < n){
			tab[i] = ite.first;
			temp--;
			i++;
		}
		
		if(tab[i] > ite.first || i == (n-1))
			break;
	}
	
	unsigned long long suma = 0;
	//cout << "tab after: " << endl;
	for(int i = 0; i < n; i++){
		//cout << tab[i] << " ";
		suma += tab[i];
	} 
	
	cout << suma << endl;
		
	
	
	return 0;
}


Measured memory_bytes: 3188