#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm> 
using namespace std;
typedef long long ll;
int main()
{
	map<int,int> m;
	int N,M;
	scanf("%d%d",&N,&M);
	int a[N];
	for(int i=0;i<N;++i) scanf("%d",&a[i]);
	sort(a,a+N);
	int x,y;
	for(int i=0;i<M;++i){
		scanf("%d%d",&x,&y);
		m[y]+=x;
	}
	ll ans=0;
	for(int i=0;i<N;++i){
		if(m.size()&&m.rbegin()->first>a[i]){
			a[i]=m.rbegin()->first;
			m.rbegin()->second--;
			if(m.rbegin()->second==0){
				m.erase(m.rbegin()->first);
			}
		}
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}
