#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
#define F first
#define S second
using namespace std;

typedef long long ll;
ll n, m, s, a[N], t[N];
pair<ll, ll> b[N];
int main()
{
	int i, j, k;
	cin >> n >> m;
	for (i = 0; i < n; i++) scanf("%lld", &a[i]);
	sort(a, a + n);
	for (i = 0; i < m; i++) scanf("%lld %lld", &b[i].S, &b[i].F);
	sort(b, b + m);
	k = 0;
	for (i = m - 1; i >= 0; i--) {
		for (j = 0; j < b[i].S && k < n; j++, k++) {
			t[k] = b[i].F;
		}
	}
	for (i = 0; i < n; i++) s += max(a[i], t[i]);
    cout << s << endl;
    return 0;
}