#include <iostream>
#include <map>

using namespace std;

int main() {
	int N,M;
	cin >> N >> M;

	map<int,int> A;

	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		A[a]++;
	}

	for (int i = 0; i < M; i++) {
		int b, c;
		cin >> b >> c;
		A[c] += b;
	}

	auto i = A.rbegin();
	long long ans = 0;
	int count = 0;
	for (; i != A.rend();i++) {
		if (count + i->second > N) {
			ans += (long long)i->first * (N - count);
			break;
		}
		count += i->second;
		ans += (long long)i->first * i->second;
	}

	cout << ans << endl;

	return 0;
}