#include <bits/stdc++.h>
using namespace std;
int n,m,a[100005],b[100005],c[100005];
struct A{
	int b,c;
	bool operator <(const A &nt) const{
		return c>nt.c;
	}
}oh[100005];
signed main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<=m;i++) scanf("%d%d",&oh[i].b,&oh[i].c);
	sort(oh+1,oh+1+m);
	int i=1,j=1;
	while(oh[i].c>a[j]&&i<=m&&j<=n){
		a[j]=oh[i].c;
		j++;
		oh[i].b--;
		if(!oh[i].b) i++;
	}
	long long ans=0;
	for(int i=1;i<=n;i++) ans+=a[i];
	printf("%lld",ans);
}