#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, m;
	cin >> n >> m;

	priority_queue<pair<long long,int>> v;
	for(int i=0; i<n; ++i){
		int a;
		cin >> a;
		v.push(make_pair(a,1));
	}
	for(int i=0; i<m; ++i){
		int b, c;
		cin >> b >> c;
		v.push(make_pair(c,b));
	}
	
	long long ans=0;
	int cnt=0;
	for(int i=0; i<n+m && cnt<n; ++i){
		auto z=v.top();
		v.pop();
		if(cnt+z.second>=n){
			ans += z.first*(n-cnt);
			break;
		}
		ans += z.first*z.second;
		cnt += z.second;
	}
	cout << ans << endl;
}